From 88a104a6d41ed2d982e11d3d5e0b26b5d28272fd Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 12 Feb 2026 17:57:31 +0100 Subject: [PATCH] Swap receiver and parameter for a nicer code. --- .../DefaultNotificationDrawerManager.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 0f64037aee..e328c46209 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 @@ -109,7 +109,7 @@ class DefaultNotificationDrawerManager( } suspend fun onNotifiableEventsReceived(notifiableEvents: List) { - val eventsToNotify = notifiableEvents.filter { !it.shouldIgnoreRegardingApplicationState(appNavigationStateService.appNavigationState.value) } + val eventsToNotify = notifiableEvents.filter { !appNavigationStateService.appNavigationState.value.shouldIgnoreEvent(it) } renderEvents(eventsToNotify) } @@ -213,12 +213,12 @@ class DefaultNotificationDrawerManager( } /** - * Used to check if a notification should be ignored based on the current application navigation state. + * Used to check if a notifiableEvent should be ignored based on the current application navigation state. */ -private fun NotifiableEvent.shouldIgnoreRegardingApplicationState(appNavigationState: AppNavigationState): Boolean { - if (!appNavigationState.isInForeground) return false - return appNavigationState.navigationState.currentSessionId() == sessionId && - when (this) { +private fun AppNavigationState.shouldIgnoreEvent(event: NotifiableEvent): Boolean { + if (!isInForeground) return false + return navigationState.currentSessionId() == event.sessionId && + when (event) { is NotifiableRingingCallEvent -> { // Never ignore ringing call notifications // Note that NotifiableRingingCallEvent are not handled by DefaultNotificationDrawerManager @@ -226,15 +226,15 @@ private fun NotifiableEvent.shouldIgnoreRegardingApplicationState(appNavigationS } is FallbackNotifiableEvent -> { // Ignore if the room list is currently displayed - appNavigationState.navigationState is NavigationState.Session + navigationState is NavigationState.Session } is InviteNotifiableEvent, is SimpleNotifiableEvent -> { - roomId == appNavigationState.navigationState.currentRoomId() + event.roomId == navigationState.currentRoomId() } is NotifiableMessageEvent -> { - roomId == appNavigationState.navigationState.currentRoomId() && - threadId == appNavigationState.navigationState.currentThreadId() + event.roomId == navigationState.currentRoomId() && + event.threadId == navigationState.currentThreadId() } } }