From 29aa188c0f4d66ab1cf76315cd4ce05271ffdda1 Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Mon, 21 Aug 2023 12:51:12 -0700 Subject: [PATCH] Fix changing tabs marking conversation read --- ts/state/ducks/conversations.ts | 2 ++ ts/state/smart/ChatsTab.tsx | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 140b8288cd90..4d739491b5b3 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -3947,6 +3947,8 @@ function showConversation({ if (nav.selectedNavTab !== NavTab.Chats) { dispatch(navActions.changeNavTab(NavTab.Chats)); + const conversation = window.ConversationController.get(conversationId); + conversation?.setMarkedUnread(false); } if (conversationId === conversations.selectedConversationId) { diff --git a/ts/state/smart/ChatsTab.tsx b/ts/state/smart/ChatsTab.tsx index 6dffdc4bfc07..32b7707bf2c0 100644 --- a/ts/state/smart/ChatsTab.tsx +++ b/ts/state/smart/ChatsTab.tsx @@ -79,16 +79,16 @@ export function SmartChatsTab(): JSX.Element { scrollToMessage(selectedConversationId, targetedMessage); } - if (!selectedConversationId) { - return; + if ( + selectedConversationId != null && + selectedConversationId !== prevConversationId + ) { + const conversation = window.ConversationController.get( + selectedConversationId + ); + strictAssert(conversation, 'Conversation must be found'); + conversation.setMarkedUnread(false); } - - const conversation = window.ConversationController.get( - selectedConversationId - ); - strictAssert(conversation, 'Conversation must be found'); - - conversation.setMarkedUnread(false); }, [ onConversationClosed, onConversationOpened,