android, desktop: fix crash on marking chat read (#4671)

This commit is contained in:
Stanislav Dmitrenko
2024-08-13 17:56:47 +00:00
committed by GitHub
parent c72c461306
commit cd1550a14d
@@ -472,7 +472,10 @@ fun ChatView(staleChatId: State<String?>, 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,