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) ## 12.102.1 (2022/01/27)
### Bugfixes ### Bugfixes
- チャットが表示できない問題を修正 - チャットが表示できない問題を修正

View File

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