From 4f72ade6567dc8986132cc8853335c93288a15a4 Mon Sep 17 00:00:00 2001 From: Fairy-Phy Date: Thu, 29 Feb 2024 22:21:19 +0900 Subject: [PATCH] feat (client): pull-to-refresh timelines based on https://github.com/misskey-dev/misskey/pull/12113 Co-authored-by: syuilo Co-authored-by: naskya Co-authored-by: Nanaka Hiira --- locales/en-US.yml | 6 + locales/ja-JP.yml | 6 + packages/client/src/components/MkDrive.vue | 4 +- .../client/src/components/MkFollowButton.vue | 3 +- .../client/src/components/MkNoteDetailed.vue | 4 +- packages/client/src/components/MkNotes.vue | 7 +- .../client/src/components/MkNotification.vue | 4 +- .../client/src/components/MkNotifications.vue | 6 +- .../client/src/components/MkPageWindow.vue | 1 + .../client/src/components/MkPagination.vue | 12 +- packages/client/src/components/MkPostForm.vue | 4 +- .../client/src/components/MkPullToRefresh.vue | 239 ++++++++++++++++++ packages/client/src/components/MkTimeline.vue | 192 ++++++++------ packages/client/src/init.ts | 5 +- .../src/pages/admin/overview.metrics.vue | 4 +- .../client/src/pages/admin/overview.queue.vue | 3 +- packages/client/src/pages/admin/overview.vue | 4 +- .../client/src/pages/admin/queue.chart.vue | 3 +- packages/client/src/pages/messaging/index.vue | 3 +- .../pages/messaging/messaging-room.form.vue | 4 +- .../src/pages/messaging/messaging-room.vue | 4 +- .../client/src/pages/settings/general.vue | 32 +++ .../pages/settings/preferences-backups.vue | 6 +- packages/client/src/pages/timeline.vue | 13 +- packages/client/src/pizzax.ts | 3 +- packages/client/src/scripts/select-file.ts | 4 +- .../client/src/scripts/use-note-capture.ts | 4 +- packages/client/src/store.ts | 12 + packages/client/src/stream.ts | 46 +++- packages/client/src/ui/_common_/common.vue | 4 +- .../src/ui/_common_/stream-indicator.vue | 4 +- packages/client/src/ui/universal.vue | 2 +- packages/client/src/widgets/job-queue.vue | 3 +- packages/client/src/widgets/photos.vue | 3 +- .../src/widgets/server-metric/index.vue | 3 +- packages/firefish-js/src/streaming.ts | 2 +- 36 files changed, 534 insertions(+), 125 deletions(-) create mode 100644 packages/client/src/components/MkPullToRefresh.vue diff --git a/locales/en-US.yml b/locales/en-US.yml index a3cd68ba0b..b9b90fbb34 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1176,6 +1176,12 @@ private: "Private" privateDescription: "Make visible for you only" makePrivate: "Make private" makePrivateConfirm: "This operation will send a deletion request to remote servers and change the visibility to private. Proceed?" +enablePullToRefresh: "Enable \"Pull down to refresh\"" +pullToRefreshThreshold: "Pull distance for reloading" +pullDownToReload: "Pull down to reload" +releaseToReload: "Release to reload" +reloading: "Reloading" +enableTimelineStreaming: "Update timelines automatically" _emojiModPerm: unauthorized: "None" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index cd974bb479..d6cbc212ff 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -997,6 +997,12 @@ detectPostLanguage: "投稿の言語を自動検出し、外国語の投稿に iconSet: "アイコンのスタイル" useCdn: "CDNのアセットを利用する" useCdnDescription: "このFirefishサーバーからではなくJSDelivr CDNからTwiemojiなどのアセットを読み込みます。" +enablePullToRefresh: "「下に引っ張って再読み込み」を有効にする" +pullToRefreshThreshold: "再読み込みするために引っ張る距離" +pullDownToReload: "下に引っ張って再読み込み" +releaseToReload: "離して再読み込み" +reloading: "読み込み中" +enableTimelineStreaming: "タイムラインを自動で更新する" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てられます。サーバーの負荷が少し増えます。" diff --git a/packages/client/src/components/MkDrive.vue b/packages/client/src/components/MkDrive.vue index 68f75b12c7..be8e0aade5 100644 --- a/packages/client/src/components/MkDrive.vue +++ b/packages/client/src/components/MkDrive.vue @@ -151,7 +151,7 @@ import XNavFolder from "@/components/MkDrive.navFolder.vue"; import XFolder from "@/components/MkDrive.folder.vue"; import XFile from "@/components/MkDrive.file.vue"; import * as os from "@/os"; -import { stream } from "@/stream"; +import { useStream } from "@/stream"; import { defaultStore } from "@/store"; import { i18n } from "@/i18n"; import { uploadFile, uploads } from "@/scripts/upload"; @@ -183,6 +183,8 @@ const emit = defineEmits<{ (ev: "open-folder", v: entities.DriveFolder): void; }>(); +const stream = useStream(); + const loadMoreFiles = ref>(); const fileInput = ref(); diff --git a/packages/client/src/components/MkFollowButton.vue b/packages/client/src/components/MkFollowButton.vue index b57c1b0bb4..e705e8c89c 100644 --- a/packages/client/src/components/MkFollowButton.vue +++ b/packages/client/src/components/MkFollowButton.vue @@ -64,7 +64,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from "vue"; import type { entities } from "firefish-js"; import * as os from "@/os"; -import { stream } from "@/stream"; +import { useStream } from "@/stream"; import { i18n } from "@/i18n"; import { $i, isSignedIn } from "@/reactiveAccount"; import { getUserMenu } from "@/scripts/get-user-menu"; @@ -72,6 +72,7 @@ import { useRouter } from "@/router"; import { vibrate } from "@/scripts/vibrate"; import icon from "@/scripts/icon"; +const stream = useStream(); const router = useRouter(); const emit = defineEmits(["refresh"]); diff --git a/packages/client/src/components/MkNoteDetailed.vue b/packages/client/src/components/MkNoteDetailed.vue index 3ef580b242..fd873115b0 100644 --- a/packages/client/src/components/MkNoteDetailed.vue +++ b/packages/client/src/components/MkNoteDetailed.vue @@ -185,7 +185,7 @@ import { i18n } from "@/i18n"; import { getNoteMenu } from "@/scripts/get-note-menu"; import { useNoteCapture } from "@/scripts/use-note-capture"; import { deepClone } from "@/scripts/clone"; -import { stream } from "@/stream"; +import { useStream } from "@/stream"; // import icon from "@/scripts/icon"; const props = defineProps<{ @@ -193,6 +193,8 @@ const props = defineProps<{ pinned?: boolean; }>(); +const stream = useStream(); + const tab = ref("replies"); const note = ref(deepClone(props.note)); diff --git a/packages/client/src/components/MkNotes.vue b/packages/client/src/components/MkNotes.vue index f64100a6fd..07ed2c3f12 100644 --- a/packages/client/src/components/MkNotes.vue +++ b/packages/client/src/components/MkNotes.vue @@ -1,5 +1,9 @@