1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-03 12:36:06 +02:00

fix(frontend): ノート購読の挙動改善 (#16023)

* fix(frontend): ノート購読の挙動改善

* fix

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
かっこかり
2025-05-11 15:53:02 +09:00
committed by GitHub
parent 3df421da1a
commit c793038a8b
4 changed files with 51 additions and 14 deletions

View File

@@ -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: () => {
// すでに購読しているので何もしない
},
};
}