Update the app badge and clear read notifications on room list updates

The sync update action is sent from the room list service state listener,
which fires before the SDK has applied the new unread counts, leaving the
app badge one sync behind. Drive both the badge and the clearing of
delivered notifications for fully read rooms from the room list publisher
instead, moving the observer from the ChatsTabFlowCoordinator into the
UserSessionFlowCoordinator.

The NotificationManager now receives the badge count from the caller so the
same value can be reused elsewhere.
This commit is contained in:
Stefan Ceriu
2026-10-08 14:30:28 +03:00
parent 61fe2a8158
commit ab39d8de06
6 changed files with 39 additions and 18 deletions
@@ -9039,11 +9039,25 @@ nonisolated class NotificationManagerMock: NotificationManagerProtocol, @uncheck
var updateAppBadgeCountCalled: Bool {
return updateAppBadgeCountCallsCount > 0
}
nonisolated(unsafe) var updateAppBadgeCountClosure: (() async -> Void)?
private let updateAppBadgeCountReceivedBadgeCountLock = NSLock()
private nonisolated(unsafe) var updateAppBadgeCountUnderlyingReceivedBadgeCount: Int?
var updateAppBadgeCountReceivedBadgeCount: Int? {
get { updateAppBadgeCountReceivedBadgeCountLock.withLock { updateAppBadgeCountUnderlyingReceivedBadgeCount } }
set { updateAppBadgeCountReceivedBadgeCountLock.withLock { updateAppBadgeCountUnderlyingReceivedBadgeCount = newValue } }
}
private let updateAppBadgeCountReceivedInvocationsLock = NSLock()
private nonisolated(unsafe) var updateAppBadgeCountUnderlyingReceivedInvocations: [Int] = []
var updateAppBadgeCountReceivedInvocations: [Int] {
get { updateAppBadgeCountReceivedInvocationsLock.withLock { updateAppBadgeCountUnderlyingReceivedInvocations } }
set { updateAppBadgeCountReceivedInvocationsLock.withLock { updateAppBadgeCountUnderlyingReceivedInvocations = newValue } }
}
nonisolated(unsafe) var updateAppBadgeCountClosure: ((Int) async -> Void)?
@concurrent func updateAppBadgeCount() async {
@concurrent func updateAppBadgeCount(_ badgeCount: Int) async {
updateAppBadgeCountCallsCountLock.withLock { updateAppBadgeCountUnderlyingCallsCount += 1 }
await updateAppBadgeCountClosure?()
updateAppBadgeCountReceivedBadgeCount = badgeCount
updateAppBadgeCountReceivedInvocationsLock.withLock { updateAppBadgeCountUnderlyingReceivedInvocations.append(badgeCount) }
await updateAppBadgeCountClosure?(badgeCount)
}
}
nonisolated class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol, @unchecked Sendable {