fix(client): 投稿のNSFW画像を表示したあとにリアクションが更新されると画像が非表示になる問題を修正

Fix #8208
This commit is contained in:
syuilo 2022-01-28 01:05:31 +09:00
parent a9960ac63a
commit 389350ba77
2 changed files with 14 additions and 21 deletions

View File

@ -7,6 +7,13 @@
-->
## 12.x.x (unreleased)
### Improvements
### Bugfixes
- 投稿のNSFW画像を表示したあとにリアクションが更新されると画像が非表示になる問題を修正
## 12.102.1 (2022/01/27)
### Bugfixes
- チャットが表示できない問題を修正

View File

@ -19,51 +19,41 @@ export function useNoteCapture(props: {
case 'reacted': {
const reaction = body.reaction;
const updated = JSON.parse(JSON.stringify(appearNote.value));
if (body.emoji) {
const emojis = appearNote.value.emojis || [];
if (!emojis.includes(body.emoji)) {
updated.emojis = [...emojis, body.emoji];
appearNote.value.emojis = [...emojis, body.emoji];
}
}
// TODO: reactionsプロパティがない場合ってあったっけ なければ || {} は消せる
const currentCount = (appearNote.value.reactions || {})[reaction] || 0;
updated.reactions[reaction] = currentCount + 1;
appearNote.value.reactions[reaction] = currentCount + 1;
if ($i && (body.userId === $i.id)) {
updated.myReaction = reaction;
appearNote.value.myReaction = reaction;
}
appearNote.value = updated;
break;
}
case 'unreacted': {
const reaction = body.reaction;
const updated = JSON.parse(JSON.stringify(appearNote.value));
// TODO: reactionsプロパティがない場合ってあったっけ なければ || {} は消せる
const currentCount = (appearNote.value.reactions || {})[reaction] || 0;
updated.reactions[reaction] = Math.max(0, currentCount - 1);
appearNote.value.reactions[reaction] = Math.max(0, currentCount - 1);
if ($i && (body.userId === $i.id)) {
updated.myReaction = null;
appearNote.value.myReaction = null;
}
appearNote.value = updated;
break;
}
case 'pollVoted': {
const choice = body.choice;
const updated = JSON.parse(JSON.stringify(appearNote.value));
const choices = [...appearNote.value.poll.choices];
choices[choice] = {
...choices[choice],
@ -73,16 +63,12 @@ export function useNoteCapture(props: {
} : {})
};
updated.poll.choices = choices;
appearNote.value = updated;
appearNote.value.poll.choices = choices;
break;
}
case 'deleted': {
const updated = JSON.parse(JSON.stringify(appearNote.value));
updated.value = true;
appearNote.value = updated;
appearNote.value.deletedAt = new Date();
break;
}
}