fix(frontend): リアクション削除イベントのコンディションが誤っていたのを修正 (#16097)
This commit is contained in:
parent
fab9db405c
commit
0504d4399c
|
@ -187,6 +187,8 @@ export type ReactiveNoteData = {
|
|||
pollChoices: NonNullable<Misskey.entities.Note['poll']>['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<Misskey.entities.User['id'], string>();
|
||||
const reactionUserMap = new Map<Misskey.entities.User['id'], string | typeof noReaction>();
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue