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
@@ -161,11 +161,9 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
notificationCenter.removeDeliveredNotifications(withIdentifiers: notificationsIdentifiers)
}
func updateAppBadgeCount() async {
func updateAppBadgeCount(_ badgeCount: Int) async {
guard let userSession else { return }
let badgeCount = Int(userSession.clientProxy.totalUnreadNotifications)
appSettings.lastKnownBadgeCount = badgeCount
MXLog.debug("Updating app badge count to \(badgeCount)")
@@ -37,5 +37,5 @@ protocol NotificationManagerProtocol: AnyObject {
func removeDeliveredNotificationsForFullyReadRooms(_ rooms: [RoomSummary]) async
func updateAppBadgeCount() async
func updateAppBadgeCount(_ badgeCount: Int) async
}