Simplify again the code.

This commit is contained in:
Benoit Marty
2023-09-15 15:22:25 +02:00
committed by Benoit Marty
parent e0cef81118
commit f0bb391519
2 changed files with 4 additions and 5 deletions

View File

@@ -224,7 +224,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
doRender: Boolean,
action: (NotificationEventQueue) -> Unit,
) {
notificationState.updateQueuedEvents(this) { queuedEvents, _ ->
notificationState.updateQueuedEvents { queuedEvents, _ ->
action(queuedEvents)
}
coroutineScope.refreshNotificationDrawer(doRender)
@@ -247,7 +247,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
private suspend fun refreshNotificationDrawerBg(doRender: Boolean) {
Timber.v("refreshNotificationDrawerBg()")
val eventsToRender = notificationState.updateQueuedEvents(this) { queuedEvents, renderedEvents ->
val eventsToRender = notificationState.updateQueuedEvents { queuedEvents, renderedEvents ->
notifiableEventProcessor.process(queuedEvents.rawEvents(), renderedEvents).also {
queuedEvents.clearAndAdd(it.onlyKeptEvents())
}

View File

@@ -39,11 +39,10 @@ class NotificationState(
) {
fun <T> updateQueuedEvents(
drawerManager: DefaultNotificationDrawerManager,
action: DefaultNotificationDrawerManager.(NotificationEventQueue, List<ProcessedEvent<NotifiableEvent>>) -> T
action: (NotificationEventQueue, List<ProcessedEvent<NotifiableEvent>>) -> T
): T {
return synchronized(queuedEvents) {
action(drawerManager, queuedEvents, renderedEvents)
action(queuedEvents, renderedEvents)
}
}