Swap receiver and parameter for a nicer code.
This commit is contained in:
parent
130ff40e5c
commit
88a104a6d4
1 changed files with 10 additions and 10 deletions
|
|
@ -109,7 +109,7 @@ class DefaultNotificationDrawerManager(
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun onNotifiableEventsReceived(notifiableEvents: List<NotifiableEvent>) {
|
suspend fun onNotifiableEventsReceived(notifiableEvents: List<NotifiableEvent>) {
|
||||||
val eventsToNotify = notifiableEvents.filter { !it.shouldIgnoreRegardingApplicationState(appNavigationStateService.appNavigationState.value) }
|
val eventsToNotify = notifiableEvents.filter { !appNavigationStateService.appNavigationState.value.shouldIgnoreEvent(it) }
|
||||||
renderEvents(eventsToNotify)
|
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 {
|
private fun AppNavigationState.shouldIgnoreEvent(event: NotifiableEvent): Boolean {
|
||||||
if (!appNavigationState.isInForeground) return false
|
if (!isInForeground) return false
|
||||||
return appNavigationState.navigationState.currentSessionId() == sessionId &&
|
return navigationState.currentSessionId() == event.sessionId &&
|
||||||
when (this) {
|
when (event) {
|
||||||
is NotifiableRingingCallEvent -> {
|
is NotifiableRingingCallEvent -> {
|
||||||
// Never ignore ringing call notifications
|
// Never ignore ringing call notifications
|
||||||
// Note that NotifiableRingingCallEvent are not handled by DefaultNotificationDrawerManager
|
// Note that NotifiableRingingCallEvent are not handled by DefaultNotificationDrawerManager
|
||||||
|
|
@ -226,15 +226,15 @@ private fun NotifiableEvent.shouldIgnoreRegardingApplicationState(appNavigationS
|
||||||
}
|
}
|
||||||
is FallbackNotifiableEvent -> {
|
is FallbackNotifiableEvent -> {
|
||||||
// Ignore if the room list is currently displayed
|
// Ignore if the room list is currently displayed
|
||||||
appNavigationState.navigationState is NavigationState.Session
|
navigationState is NavigationState.Session
|
||||||
}
|
}
|
||||||
is InviteNotifiableEvent,
|
is InviteNotifiableEvent,
|
||||||
is SimpleNotifiableEvent -> {
|
is SimpleNotifiableEvent -> {
|
||||||
roomId == appNavigationState.navigationState.currentRoomId()
|
event.roomId == navigationState.currentRoomId()
|
||||||
}
|
}
|
||||||
is NotifiableMessageEvent -> {
|
is NotifiableMessageEvent -> {
|
||||||
roomId == appNavigationState.navigationState.currentRoomId() &&
|
event.roomId == navigationState.currentRoomId() &&
|
||||||
threadId == appNavigationState.navigationState.currentThreadId()
|
event.threadId == navigationState.currentThreadId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue