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;