From 0504d4399c6943beee12ac54addd042ef59e33e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 25 May 2025 08:38:29 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E3=83=AA=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=89=8A=E9=99=A4=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E3=82=B3=E3=83=B3=E3=83=87=E3=82=A3?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E8=AA=A4=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=20(#1609?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/composables/use-note-capture.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/composables/use-note-capture.ts b/packages/frontend/src/composables/use-note-capture.ts index a8f4a5a2a9..90a5922b3e 100644 --- a/packages/frontend/src/composables/use-note-capture.ts +++ b/packages/frontend/src/composables/use-note-capture.ts @@ -187,6 +187,8 @@ export type ReactiveNoteData = { pollChoices: NonNullable['choices']; }; +const noReaction = Symbol(); + export function useNoteCapture(props: { note: Misskey.entities.Note; parentNote: Misskey.entities.Note | null; @@ -219,7 +221,7 @@ export function useNoteCapture(props: { noteEvents.on(`pollVoted:${note.id}`, onPollVoted); // 操作がダブっていないかどうかを簡易的に記録するためのMap - const reactionUserMap = new Map(); + const reactionUserMap = new Map(); let latestPollVotedKey: string | null = null; function onReacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void { @@ -245,8 +247,9 @@ export function useNoteCapture(props: { function onUnreacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void { const normalizedName = ctx.reaction.replace(/^:(\w+):$/, ':$1@.:'); - if (!reactionUserMap.has(ctx.userId)) return; - reactionUserMap.delete(ctx.userId); + // 確実に一度リアクションされて取り消されている場合のみ処理をとめる(APIで初回読み込み→Streamでアップデート等の場合、reactionUserMapに情報がないため) + if (reactionUserMap.has(ctx.userId) && reactionUserMap.get(ctx.userId) === noReaction) return; + reactionUserMap.set(ctx.userId, noReaction); const currentCount = $note.reactions[normalizedName] || 0;