fix: その場で書き換えることで再レンダリングを最小限に抑える(かも)
This commit is contained in:
parent
aaf93607bc
commit
7081c4f30e
|
@ -196,17 +196,18 @@ export function useNoteCapture(props: {
|
||||||
} {
|
} {
|
||||||
const { note, parentNote, $note } = props;
|
const { note, parentNote, $note } = props;
|
||||||
|
|
||||||
// Normalize reactions
|
// Normalize reactions in-place
|
||||||
if (Object.keys($note.reactions).length > 0) {
|
for (const name of Object.keys($note.reactions)) {
|
||||||
$note.reactions = Object.entries($note.reactions).reduce((acc, [name, count]) => {
|
const normalizedName = name.replace(/^:(\w+):$/, ':$1@.:');
|
||||||
const normalizedName = name.replace(/^:(\w+):$/, ':$1@.:');
|
if (normalizedName !== name) {
|
||||||
if (acc[normalizedName] == null) {
|
const count = $note.reactions[name];
|
||||||
acc[normalizedName] = count;
|
if ($note.reactions[normalizedName] == null) {
|
||||||
|
$note.reactions[normalizedName] = count;
|
||||||
} else {
|
} else {
|
||||||
acc[normalizedName] += count;
|
$note.reactions[normalizedName] += count;
|
||||||
}
|
}
|
||||||
return acc;
|
delete $note.reactions[name];
|
||||||
}, {} as Misskey.entities.Note['reactions']);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
noteEvents.on(`reacted:${note.id}`, onReacted);
|
noteEvents.on(`reacted:${note.id}`, onReacted);
|
||||||
|
|
Loading…
Reference in New Issue