Introduce a local mechanism for managing the app's badge count

This commit is contained in:
Stefan Ceriu
2026-09-08 19:05:44 +03:00
parent 7be93f8da8
commit 58628bd7c5
13 changed files with 164 additions and 6 deletions
@@ -237,6 +237,37 @@ final class NotificationManagerTests {
await notificationManager.userNotificationCenter(UNUserNotificationCenter.current(), didReceive: response)
#expect(notificationTappedDelegateCalled)
}
@Test
func updatingAppBadgeCountUsesTheClientSideCount() async {
appSettings.roomListNotificationCountEnabled = true
clientProxy.totalUnreadNotifications = 7
await notificationManager.updateAppBadgeCount()
#expect(notificationCenter.setBadgeCountReceivedNewBadgeCount == 7)
#expect(appSettings.lastKnownBadgeCount == 7)
}
@Test
func updatingAppBadgeCountWithoutASessionDoesNothing() async {
appSettings.roomListNotificationCountEnabled = true
notificationManager.setUserSession(nil)
await notificationManager.updateAppBadgeCount()
#expect(!notificationCenter.setBadgeCountCalled)
}
@Test
func updatingAppBadgeCountWithFeatureDisabledDoesNothing() async {
appSettings.roomListNotificationCountEnabled = false
clientProxy.totalUnreadNotifications = 7
await notificationManager.updateAppBadgeCount()
#expect(!notificationCenter.setBadgeCountCalled)
}
}
extension NotificationManagerTests: @MainActor NotificationManagerDelegate {