From 6a6c3b7c2719a6cd020954714147ab787075d9d0 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 5 Mar 2026 15:50:37 +0530 Subject: [PATCH] fix: mark message read --- app/javascript/ui/MessageList.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/javascript/ui/MessageList.vue b/app/javascript/ui/MessageList.vue index 3bf5065c3..376d8d72e 100644 --- a/app/javascript/ui/MessageList.vue +++ b/app/javascript/ui/MessageList.vue @@ -81,12 +81,21 @@ onMounted(async () => { ]); }); -watch(conversation, () => { - store.dispatch('setActiveChat', { - data: { - id: conversation.value.id, - }, +watch(conversation, async (newConversation, oldConversation) => { + if (!newConversation?.id) return; + + await store.dispatch('setActiveChat', { + data: newConversation, }); + + if ( + newConversation.id !== oldConversation?.id && + newConversation.unread_count > 0 + ) { + store.dispatch('markMessagesRead', { + id: newConversation.id, + }); + } }); useInfiniteScroll(messageListRef, useThrottleFn(fetchMore, 1000), {