From 107b6e1aec9e4b6acb31550bc30c3aa7fe9efe39 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:06:42 +0300 Subject: [PATCH] multiplatform: mark read fix (#2932) Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 78b379df7..fbe5746c6 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -66,11 +66,11 @@ fun ChatView(chatId: String, chatModel: ChatModel, onComposed: () -> Unit) { launch { snapshotFlow { chatModel.chatId.value } .distinctUntilChanged() - .collect { - if (activeChat.value?.id != chatModel.chatId.value && chatModel.chatId.value != null) { + .collect { chatId -> + if (activeChat.value?.id != chatId && chatId != null) { // Redisplay the whole hierarchy if the chat is different to make going from groups to direct chat working correctly // Also for situation when chatId changes after clicking in notification, etc - activeChat.value = chatModel.getChat(chatModel.chatId.value!!) + activeChat.value = chatModel.getChat(chatId) } markUnreadChatAsRead(activeChat, chatModel) } @@ -842,7 +842,7 @@ fun BoxWithConstraintsScope.ChatItemsList( } } - if (cItem.isRcvNew) { + if (cItem.isRcvNew && chat.id == ChatModel.chatId.value) { LaunchedEffect(cItem.id) { scope.launch { delay(600)