fix(frontend): リアクション削除イベントのコンディションが誤っていたのを修正 (#16097)

This commit is contained in:
かっこかり 2025-05-25 08:38:29 +09:00 committed by GitHub
parent fab9db405c
commit 0504d4399c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -187,6 +187,8 @@ export type ReactiveNoteData = {
pollChoices: NonNullable<Misskey.entities.Note['poll']>['choices']; pollChoices: NonNullable<Misskey.entities.Note['poll']>['choices'];
}; };
const noReaction = Symbol();
export function useNoteCapture(props: { export function useNoteCapture(props: {
note: Misskey.entities.Note; note: Misskey.entities.Note;
parentNote: Misskey.entities.Note | null; parentNote: Misskey.entities.Note | null;
@ -219,7 +221,7 @@ export function useNoteCapture(props: {
noteEvents.on(`pollVoted:${note.id}`, onPollVoted); noteEvents.on(`pollVoted:${note.id}`, onPollVoted);
// 操作がダブっていないかどうかを簡易的に記録するためのMap // 操作がダブっていないかどうかを簡易的に記録するためのMap
const reactionUserMap = new Map<Misskey.entities.User['id'], string>(); const reactionUserMap = new Map<Misskey.entities.User['id'], string | typeof noReaction>();
let latestPollVotedKey: string | null = null; let latestPollVotedKey: string | null = null;
function onReacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void { 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 { function onUnreacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void {
const normalizedName = ctx.reaction.replace(/^:(\w+):$/, ':$1@.:'); const normalizedName = ctx.reaction.replace(/^:(\w+):$/, ':$1@.:');
if (!reactionUserMap.has(ctx.userId)) return; // 確実に一度リアクションされて取り消されている場合のみ処理をとめるAPIで初回読み込み→Streamでアップデート等の場合、reactionUserMapに情報がないため
reactionUserMap.delete(ctx.userId); if (reactionUserMap.has(ctx.userId) && reactionUserMap.get(ctx.userId) === noReaction) return;
reactionUserMap.set(ctx.userId, noReaction);
const currentCount = $note.reactions[normalizedName] || 0; const currentCount = $note.reactions[normalizedName] || 0;