mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 12:19:54 +00:00
android, desktop: marking chat read fix (#5658)
* android, desktop: marking chat read fix * comments
This commit is contained in:
parent
41ccb14bfa
commit
c81fa7e6b0
3 changed files with 7 additions and 3 deletions
|
@ -1612,6 +1612,7 @@ public struct ChatStats: Decodable, Hashable {
|
|||
// actual only via getChats() and getChat(.initial), otherwise, zero
|
||||
public var reportsCount: Int = 0
|
||||
public var minUnreadItemId: Int64 = 0
|
||||
// actual only via getChats(), otherwise, false
|
||||
public var unreadChat: Bool = false
|
||||
}
|
||||
|
||||
|
|
|
@ -1233,10 +1233,11 @@ data class Chat(
|
|||
@Serializable
|
||||
data class ChatStats(
|
||||
val unreadCount: Int = 0,
|
||||
// actual only via getChats() and getChat(.initial), otherwise, zero
|
||||
val unreadMentions: Int = 0,
|
||||
// actual only via getChats() and getChat(.initial), otherwise, zero
|
||||
val reportsCount: Int = 0,
|
||||
val minUnreadItemId: Long = 0,
|
||||
// actual only via getChats(), otherwise, false
|
||||
val unreadChat: Boolean = false
|
||||
)
|
||||
|
||||
|
|
|
@ -54,11 +54,13 @@ suspend fun processLoadedChat(
|
|||
if (contentTag == null) {
|
||||
// update main chats, not content tagged
|
||||
withChats {
|
||||
if (getChat(chat.id) == null) {
|
||||
val oldChat = getChat(chat.id)
|
||||
if (oldChat == null) {
|
||||
addChat(chat)
|
||||
} else {
|
||||
updateChatInfo(chat.remoteHostId, chat.chatInfo)
|
||||
updateChatStats(chat.remoteHostId, chat.id, chat.chatStats)
|
||||
// unreadChat is currently not actual in getChat query (always false)
|
||||
updateChatStats(chat.remoteHostId, chat.id, chat.chatStats.copy(unreadChat = oldChat.chatStats.unreadChat))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue