diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManager.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManager.kt index 3dbf09e227..575206de10 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManager.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManager.kt @@ -71,7 +71,10 @@ class DefaultNotificationDrawerManager( private fun onAppNavigationStateChange(navigationState: NavigationState) { when (navigationState) { NavigationState.Root -> {} - is NavigationState.Session -> {} + is NavigationState.Session -> { + // Cleanup the fallback notification + clearFallbackForSession(navigationState.sessionId) + } is NavigationState.Room -> { // Cleanup notification for current room clearMessagesForRoom( @@ -121,6 +124,17 @@ class DefaultNotificationDrawerManager( .forEach { notificationDisplayer.cancelNotification(it.tag, it.id) } } + /** + * Remove the fallback notification for the session. + */ + fun clearFallbackForSession(sessionId: SessionId) { + notificationDisplayer.cancelNotification( + DefaultNotificationDataFactory.FALLBACK_NOTIFICATION_TAG, + NotificationIdProvider.getFallbackNotificationId(sessionId), + ) + clearSummaryNotificationIfNeeded(sessionId) + } + /** * Should be called when the application is currently opened and showing timeline for the given [roomId]. * Used to ignore events related to that room (no need to display notification) and clean any existing notification on this room. diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactory.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactory.kt index 5331519110..957894e994 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactory.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactory.kt @@ -149,7 +149,7 @@ class DefaultNotificationDataFactory( fallback, ) return OneShotNotification( - tag = "FALLBACK", + tag = FALLBACK_NOTIFICATION_TAG, notification = notification, isNoisy = false, timestamp = fallback.first().timestamp @@ -174,6 +174,10 @@ class DefaultNotificationDataFactory( ) } } + + companion object { + const val FALLBACK_NOTIFICATION_TAG = "FALLBACK" + } } data class RoomNotification(