mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 20:01:55 +00:00
Simplify again the code.
This commit is contained in:
committed by
Benoit Marty
parent
9a461f4b74
commit
020839f17e
+2
-2
@@ -224,7 +224,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
|
|||||||
doRender: Boolean,
|
doRender: Boolean,
|
||||||
action: (NotificationEventQueue) -> Unit,
|
action: (NotificationEventQueue) -> Unit,
|
||||||
) {
|
) {
|
||||||
notificationState.updateQueuedEvents(this) { queuedEvents, _ ->
|
notificationState.updateQueuedEvents { queuedEvents, _ ->
|
||||||
action(queuedEvents)
|
action(queuedEvents)
|
||||||
}
|
}
|
||||||
coroutineScope.refreshNotificationDrawer(doRender)
|
coroutineScope.refreshNotificationDrawer(doRender)
|
||||||
@@ -247,7 +247,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
|
|||||||
|
|
||||||
private suspend fun refreshNotificationDrawerBg(doRender: Boolean) {
|
private suspend fun refreshNotificationDrawerBg(doRender: Boolean) {
|
||||||
Timber.v("refreshNotificationDrawerBg()")
|
Timber.v("refreshNotificationDrawerBg()")
|
||||||
val eventsToRender = notificationState.updateQueuedEvents(this) { queuedEvents, renderedEvents ->
|
val eventsToRender = notificationState.updateQueuedEvents { queuedEvents, renderedEvents ->
|
||||||
notifiableEventProcessor.process(queuedEvents.rawEvents(), renderedEvents).also {
|
notifiableEventProcessor.process(queuedEvents.rawEvents(), renderedEvents).also {
|
||||||
queuedEvents.clearAndAdd(it.onlyKeptEvents())
|
queuedEvents.clearAndAdd(it.onlyKeptEvents())
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -39,11 +39,10 @@ class NotificationState(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
fun <T> updateQueuedEvents(
|
fun <T> updateQueuedEvents(
|
||||||
drawerManager: DefaultNotificationDrawerManager,
|
action: (NotificationEventQueue, List<ProcessedEvent<NotifiableEvent>>) -> T
|
||||||
action: DefaultNotificationDrawerManager.(NotificationEventQueue, List<ProcessedEvent<NotifiableEvent>>) -> T
|
|
||||||
): T {
|
): T {
|
||||||
return synchronized(queuedEvents) {
|
return synchronized(queuedEvents) {
|
||||||
action(drawerManager, queuedEvents, renderedEvents)
|
action(queuedEvents, renderedEvents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user