From 0c7fa1886044d2065e5c9c6690bf643f576c1955 Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Thu, 18 Jun 2026 17:56:38 +0000 Subject: [PATCH] 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. --- apps/ios/Shared/Model/ChatModel.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/ios/Shared/Model/ChatModel.swift b/apps/ios/Shared/Model/ChatModel.swift index c95d62861f..71534fab20 100644 --- a/apps/ios/Shared/Model/ChatModel.swift +++ b/apps/ios/Shared/Model/ChatModel.swift @@ -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) {