summaryrefslogtreecommitdiff
path: root/packages/frontend/src/composables
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2025-05-11 15:53:02 +0900
committerGitHub <noreply@github.com>2025-05-11 15:53:02 +0900
commitc793038a8b7f6de6b45c5d6fddbfe3e330a7b3d2 (patch)
tree54bc341c374902256d7d2824b1f1414da30e45ce /packages/frontend/src/composables
parentrefactor(frontend): MkMarquee のコードの可読性の向上 (#16017) (diff)
downloadmisskey-c793038a8b7f6de6b45c5d6fddbfe3e330a7b3d2.tar.gz
misskey-c793038a8b7f6de6b45c5d6fddbfe3e330a7b3d2.tar.bz2
misskey-c793038a8b7f6de6b45c5d6fddbfe3e330a7b3d2.zip
fix(frontend): ノート購読の挙動改善 (#16023)
* fix(frontend): ノート購読の挙動改善 * fix --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/composables')
-rw-r--r--packages/frontend/src/composables/use-note-capture.ts40
1 files changed, 30 insertions, 10 deletions
diff --git a/packages/frontend/src/composables/use-note-capture.ts b/packages/frontend/src/composables/use-note-capture.ts
index 2f33c25a0a..dd00c2b66e 100644
--- a/packages/frontend/src/composables/use-note-capture.ts
+++ b/packages/frontend/src/composables/use-note-capture.ts
@@ -191,7 +191,9 @@ export function useNoteCapture(props: {
note: Pick<Misskey.entities.Note, 'id' | 'createdAt'>;
parentNote: Misskey.entities.Note | null;
$note: ReactiveNoteData;
-}) {
+}): {
+ subscribe: () => void;
+} {
const { note, parentNote, $note } = props;
noteEvents.on(`reacted:${note.id}`, onReacted);
@@ -254,6 +256,14 @@ export function useNoteCapture(props: {
$note.pollChoices = choices;
}
+ function subscribe() {
+ if ($i && store.s.realtimeMode) {
+ realtimeSubscribe(props);
+ } else {
+ pollingSubscribe(props);
+ }
+ }
+
onUnmounted(() => {
noteEvents.off(`reacted:${note.id}`, onReacted);
noteEvents.off(`unreacted:${note.id}`, onUnreacted);
@@ -265,19 +275,29 @@ export function useNoteCapture(props: {
// TODO: デバイスとサーバーの時計がズレていると不具合の元になるため、ズレを検知して警告を表示するなどのケアが必要かもしれない
if (parentNote == null) {
if ((Date.now() - new Date(note.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
- // リノートで表示されているノートでもないし、投稿からある程度経過しているので購読しない
- return;
+ // リノートで表示されているノートでもないし、投稿からある程度経過しているので自動で購読しない
+ return {
+ subscribe: () => {
+ subscribe();
+ },
+ };
}
} else {
if ((Date.now() - new Date(parentNote.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
- // リノートで表示されているノートだが、リノートされてからある程度経過しているので購読しない
- return;
+ // リノートで表示されているノートだが、リノートされてからある程度経過しているので自動で購読しない
+ return {
+ subscribe: () => {
+ subscribe();
+ },
+ };
}
}
- if ($i && store.s.realtimeMode) {
- realtimeSubscribe(props);
- } else {
- pollingSubscribe(props);
- }
+ subscribe();
+
+ return {
+ subscribe: () => {
+ // すでに購読しているので何もしない
+ },
+ };
}