mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-29 14:01:45 +00:00
ios: drop the unread-counter clamp - out of scope for this PR
The apply-point clamp in changeUnreadCounter (342e270a1/fb849aa2c) guarded a pre-existing, general iOS over-decrement (markChatItemsRead decrements by the requested id count regardless of whether each item still counted) that this feature neither introduces nor worsens - Android already self-clamps in decreaseCounterInPrimaryContext, iOS never did. The pending-invitee preview's support-item unread is balanced without it (+1 on receive, -1 on read/delete). Leave iOS unread untouched here; a general clamp belongs in its own change.
This commit is contained in:
@@ -1109,13 +1109,10 @@ final class ChatModel: ObservableObject {
|
||||
func changeUnreadCounter(_ chatIndex: Int, by count: Int, unreadMentions: Int) {
|
||||
let wasUnread = chats[chatIndex].unreadTag
|
||||
let stats = chats[chatIndex].chatStats
|
||||
// clamp at 0 so an over-decrement can't drive the per-chat count or the user badge negative
|
||||
// (e.g. deleting an item that never incremented the badge); feed the badge the clamped delta
|
||||
let newUnreadCount = max(stats.unreadCount + count, 0)
|
||||
chats[chatIndex].chatStats.unreadCount = newUnreadCount
|
||||
chats[chatIndex].chatStats.unreadMentions = max(stats.unreadMentions + unreadMentions, 0)
|
||||
chats[chatIndex].chatStats.unreadCount = stats.unreadCount + count
|
||||
chats[chatIndex].chatStats.unreadMentions = stats.unreadMentions + unreadMentions
|
||||
ChatTagsModel.shared.updateChatTagRead(chats[chatIndex], wasUnread: wasUnread)
|
||||
changeUnreadCounter(user: currentUser!, by: newUnreadCount - stats.unreadCount)
|
||||
changeUnreadCounter(user: currentUser!, by: count)
|
||||
}
|
||||
|
||||
func increaseUnreadCounter(user: any UserLike) {
|
||||
|
||||
Reference in New Issue
Block a user