multiplatform: mark read fix (#2932)

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
Stanislav Dmitrenko 2023-08-17 17:06:42 +03:00 committed by GitHub
parent 1d8a370c58
commit 107b6e1aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)