Skip to content

Commit 3e8d558

Browse files
committed
All messages as unread for logged account fixed.
1 parent 1d00635 commit 3e8d558

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Adamant/Services/DataProviders/AdamantChatsProvider.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,18 @@ extension AdamantChatsProvider {
188188
userInfo: [AdamantUserInfoKey.ChatProvider.lastMessageHeight:h])
189189
}
190190

191-
self?.readedLastHeight = self?.receivedLastHeight
191+
if let h = self?.receivedLastHeight {
192+
self?.readedLastHeight = h
193+
} else {
194+
self?.readedLastHeight = 0
195+
}
192196

193197
if let store = self?.securedStore {
194198
if let h = self?.receivedLastHeight {
195199
store.set(String(h), for: StoreKey.chatProvider.receivedLastHeight)
196200
}
197201

198-
if let h = self?.readedLastHeight {
202+
if let h = self?.readedLastHeight, h > 0 {
199203
store.set(String(h), for: StoreKey.chatProvider.readedLastHeight)
200204
}
201205
}
@@ -638,12 +642,6 @@ extension AdamantChatsProvider {
638642
chatroom.hasUnreadMessages = true
639643
trs.forEach({$0.isUnread = true})
640644
}
641-
} else {
642-
let msgs = Dictionary(grouping: newChatTransactions, by: ({ (t: ChatTransaction) -> Chatroom in t.chatroom!}))
643-
for (chatroom, trs) in msgs {
644-
chatroom.hasUnreadMessages = true
645-
trs.forEach({$0.isUnread = true})
646-
}
647645
}
648646

649647

0 commit comments

Comments
 (0)