From cd1550a14de32feeb4ce54f98414e2612c4a8f43 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:56:47 +0000 Subject: [PATCH] android, desktop: fix crash on marking chat read (#4671) --- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ecca3edebd..b6180c71e6 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 @@ -472,7 +472,10 @@ fun ChatView(staleChatId: State, onComposed: suspend (chatId: String) - markRead = { range, unreadCountAfter -> withBGApi { withChats { - markChatItemsRead(chatRh, chatInfo, range, unreadCountAfter) + // It's important to call it on Main thread. Otherwise, composable crash occurs from time-to-time without useful stacktrace + withContext(Dispatchers.Main) { + markChatItemsRead(chatRh, chatInfo, range, unreadCountAfter) + } ntfManager.cancelNotificationsForChat(chatInfo.id) chatModel.controller.apiChatRead( chatRh,