Display a single notification for all the fallback notifications.
When dismissed, dismiss all the fallback notifications in the model.
This commit is contained in:
parent
2d9d34b41f
commit
f409b31e8a
3 changed files with 26 additions and 1 deletions
1
changelog.d/994.bugfix
Normal file
1
changelog.d/994.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Group fallback notification to avoid having plenty of them displayed.
|
||||||
|
|
@ -136,7 +136,13 @@ data class NotificationEventQueue constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearEvent(sessionId: SessionId, eventId: EventId) {
|
fun clearEvent(sessionId: SessionId, eventId: EventId) {
|
||||||
queue.removeAll { it.sessionId == sessionId && it.eventId == eventId }
|
val isFallback = queue.firstOrNull { it.sessionId == sessionId && it.eventId == eventId } is FallbackNotifiableEvent
|
||||||
|
if (isFallback) {
|
||||||
|
Timber.d("Removing all the fallbacks")
|
||||||
|
queue.removeAll { it.sessionId == sessionId && it is FallbackNotifiableEvent }
|
||||||
|
} else {
|
||||||
|
queue.removeAll { it.sessionId == sessionId && it.eventId == eventId }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearMembershipNotificationForSession(sessionId: SessionId) {
|
fun clearMembershipNotificationForSession(sessionId: SessionId) {
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ class NotificationRenderer @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fallbackNotifications.forEach { wrapper ->
|
fallbackNotifications.forEach { wrapper ->
|
||||||
when (wrapper) {
|
when (wrapper) {
|
||||||
is OneShotNotification.Removed -> {
|
is OneShotNotification.Removed -> {
|
||||||
|
|
@ -143,6 +144,23 @@ class NotificationRenderer @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
val removedFallback = fallbackNotifications.filterIsInstance<OneShotNotification.Removed>()
|
||||||
|
val appendFallback = fallbackNotifications.filterIsInstance<OneShotNotification.Append>()
|
||||||
|
if (appendFallback.isEmpty() && removedFallback.isNotEmpty()) {
|
||||||
|
Timber.tag(loggerTag.value).d("Removing global fallback notification")
|
||||||
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
|
tag = "FALLBACK",
|
||||||
|
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId)
|
||||||
|
)
|
||||||
|
} else if (appendFallback.isNotEmpty()) {
|
||||||
|
Timber.tag(loggerTag.value).d("Showing fallback notification")
|
||||||
|
notificationDisplayer.showNotificationMessage(
|
||||||
|
tag = "FALLBACK",
|
||||||
|
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId),
|
||||||
|
notification = appendFallback.first().notification
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Update summary last to avoid briefly displaying it before other notifications
|
// Update summary last to avoid briefly displaying it before other notifications
|
||||||
if (summaryNotification is SummaryNotification.Update) {
|
if (summaryNotification is SummaryNotification.Update) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue