diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-25 16:09:19 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-25 16:09:19 +0900 |
| commit | 98554579eafd2765644c9b3ff37d33a26b6e5ceb (patch) | |
| tree | 638b04c90ab1ddbb498d84e4fdac7b046ddb89c3 /packages/frontend/src/pages/chat | |
| parent | follow up of a01ae38a07f949cbcd5ce555cd90e8570bb985cc (diff) | |
| download | misskey-98554579eafd2765644c9b3ff37d33a26b6e5ceb.tar.gz misskey-98554579eafd2765644c9b3ff37d33a26b6e5ceb.tar.bz2 misskey-98554579eafd2765644c9b3ff37d33a26b6e5ceb.zip | |
enhance: チャットのリアクションを削除できるように
Diffstat (limited to 'packages/frontend/src/pages/chat')
| -rw-r--r-- | packages/frontend/src/pages/chat/XMessage.vue | 11 | ||||
| -rw-r--r-- | packages/frontend/src/pages/chat/room.vue | 12 |
2 files changed, 22 insertions, 1 deletions
diff --git a/packages/frontend/src/pages/chat/XMessage.vue b/packages/frontend/src/pages/chat/XMessage.vue index bc348c6fb1..3dae772db1 100644 --- a/packages/frontend/src/pages/chat/XMessage.vue +++ b/packages/frontend/src/pages/chat/XMessage.vue @@ -32,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only :moveClass="prefer.s.animation ? $style.transition_reaction_move : ''" tag="div" :class="$style.reactions" > - <div v-for="record in message.reactions" :key="record.reaction + record.user.id" :class="$style.reaction"> + <div v-for="record in message.reactions" :key="record.reaction + record.user.id" :class="$style.reaction" @click="onReactionClick(record)"> <MkAvatar :user="record.user" :link="false" :class="$style.reactionAvatar"/> <MkReactionIcon :withTooltip="true" @@ -87,6 +87,15 @@ function react(ev: MouseEvent) { }); } +function onReactionClick(record: Misskey.entities.ChatMessage['reactions'][0]) { + if (record.user.id === $i.id) { + misskeyApi('chat/messages/unreact', { + messageId: props.message.id, + reaction: record.reaction, + }); + } +} + function showMenu(ev: MouseEvent) { const menu: MenuItem[] = []; diff --git a/packages/frontend/src/pages/chat/room.vue b/packages/frontend/src/pages/chat/room.vue index 8ffaf233cf..5938fd2688 100644 --- a/packages/frontend/src/pages/chat/room.vue +++ b/packages/frontend/src/pages/chat/room.vue @@ -170,6 +170,7 @@ async function initialize() { connection.value.on('message', onMessage); connection.value.on('deleted', onDeleted); connection.value.on('react', onReact); + connection.value.on('unreact', onUnreact); } else { const [r, m] = await Promise.all([ misskeyApi('chat/rooms/show', { roomId: props.roomId }), @@ -189,6 +190,7 @@ async function initialize() { connection.value.on('message', onMessage); connection.value.on('deleted', onDeleted); connection.value.on('react', onReact); + connection.value.on('unreact', onUnreact); } window.document.addEventListener('visibilitychange', onVisibilitychange); @@ -268,6 +270,16 @@ function onReact(ctx) { } } +function onUnreact(ctx) { + const message = messages.value.find(m => m.id === ctx.messageId); + if (message) { + const index = message.reactions.findIndex(r => r.reaction === ctx.reaction && r.user.id === ctx.user.id); + if (index !== -1) { + message.reactions.splice(index, 1); + } + } +} + function onIndicatorClick() { showIndicator.value = false; } |