mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-14 20:10:02 +00:00
Four fixes from adversarial review of the branch. ios: clamp the unread counter at the apply point. changeUnreadCounter(chatIndex:) applied the delta unclamped, so unreadCount could go negative and the app icon badge with it - a state that persists until the chat list reloads and that also suppresses the badge for genuinely unread messages arriving after. Reachable because the edit/delete sync added removeChatItem as a decrement source for member support items, while the count being decremented excludes them (the chat list queries filter group_scope_tag IS NULL): after a restart, moderating a still-unread support message decrements a zero. Clamped at the collector flush - its only caller - so it is correct regardless of how the debounced deltas batch, and the user/badge counter is fed the delta actually applied. Android has always done this in decreaseCounterInPrimaryContext. android, desktop: gate both primary-context mirrors on memberPending. The primary's preview block runs for a scoped ChatInfo only when memberPending, so for anyone else the mirrored call could not update a preview - it only had side effects. addChatItem's mirror re-ordered the group in the main chat list when a non-pending member replied in a member support chat, and, lacking a scope check, also re-ran the primary for sent items the dispatcher had already given it. ComposeView's edit mirror is on the live message path, so it fired on every tick to do nothing. android, desktop, ios: don't let upsertChatItem create a chat entry from a scoped ChatInfo. The memberPending exception made its "chat not found" branch reachable for support items, seeding the main list with a support item as preview - and since ChatInfo.Group.id ignores the scope, shadowing the real group rather than showing as a duplicate. On iOS it also set itemAdded, which chatItemSimpleUpdate turns into a new message notification. addChatItem never did this either. android, desktop, ios: gate the media preview exception on showChatPreviews. Treating a caption-less media support message as "has content" skips the status branch, but the next branch needs showChatPreviews and Android/desktop have no trailing else (the thumbnail is gated by the same flag) - so with previews off the row rendered empty where master showed "reviewed by admins". iOS redacted it rather than dropping it, but also lost the status. Falls back to hasMsgContent when previews are off.