-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single PushTriggerListener
dispatch
#4401
Single PushTriggerListener
dispatch
#4401
Conversation
…llback - simplifies the handling of notifications, will allow us to reduce redundant synchronisations and suspend the entire notification update (will be needed for supporting images)
…a single update point of entry for mutating the events - this avoids multiple synchronisation locks by batching updates and ensures a single notification render pass
…tifiableEventReceived not synchronised for use within the synchronized batching - makes the refresh function private as all interactions now come through via update
fun onRoomLeft(roomId: String) | ||
fun onEventRedacted(redactedEventId: String) | ||
fun batchFinish() | ||
fun onEvents(pushEvents: PushEvents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a single function here also allows up to simplfy the notification updates as we can batch all the events into one update pass, reducing the amount of synchronisation locks and redundant render passes
we might not need the private var firstThrottler = FirstThrottler(200)
anymore because of how few individual updates we make!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, You should add a file for the changelog with .removal
extension to notify SDK users about this API break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added 88fbb8f
@@ -39,14 +40,6 @@ internal class DefaultProcessEventForPushTask @Inject constructor( | |||
) : ProcessEventForPushTask { | |||
|
|||
override suspend fun execute(params: ProcessEventForPushTask.Params) { | |||
// Handle left rooms | |||
params.syncResponse.leave.keys.forEach { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these have moved to
roomsJoined = params.syncResponse.join.keys,
roomsLeft = params.syncResponse.leave.keys,
@@ -201,8 +201,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { | |||
resolvedEvent | |||
?.also { Timber.tag(loggerTag.value).d("Fast lane: notify drawer") } | |||
?.let { | |||
notificationDrawerManager.onNotifiableEventReceived(it) | |||
notificationDrawerManager.refreshNotificationDrawer() | |||
notificationDrawerManager.updateEvents { it.onNotifiableEventReceived(resolvedEvent) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateEvents
synchronises all queue mutations within the block and refreshes the drawer at the end
override fun onEvents(pushEvents: PushEvents) { | ||
session?.let { session -> | ||
val notifiableEvents = createNotifiableEvents(pushEvents, session) | ||
notificationDrawerManager.updateEvents { queuedEvents -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all notification updates from the sync response are now batched together into a single update, this enables the logic within onEvents
to be moved to a coroutine without race conditions
@@ -145,48 +148,3 @@ class NotifiableEventProcessorTest { | |||
ProcessedEvent(it.first, it.second) | |||
} | |||
} | |||
|
|||
fun aSimpleNotifiableEvent(eventId: String, type: String? = null) = SimpleNotifiableEvent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted out to their own file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one remark about the changelog
fun onRoomLeft(roomId: String) | ||
fun onEventRedacted(redactedEventId: String) | ||
fun batchFinish() | ||
fun onEvents(pushEvents: PushEvents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, You should add a file for the changelog with .removal
extension to notify SDK users about this API break.
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks way better for this class at least :)
@ouchadam please feel free to merge your approved PRs, if not targeting develop :) |
@bmarty thanks, will do! |
Some preparation/refactors around the
Push triggers
in order to support suspendingNotifiableEventResolver.resolveEvent
which is required for including images in the notifications*points to a feature branch
PushRuleListener
functions are replaced with a singleonEvents(PushEvents)
in order to allow any logic within the implementation to be asynchronousnotificationDrawerManager.updateEvents
, this ensures a single point of synchronisation and notification render pass (reduces the amount of render passes and synchronisation locks)NotifiableEvent
fixtures to a dedicated fixtures test package