Notification events resolving and rendering in batches (#4722)

- Use `NotiticationService.getNotifications()` function so we resolve the events in bulk.
- Added `NotifierResolverQueue` to group the notifications to resolve based on a debounce strategy.
- Batch rendering of these events as notifications.
This commit is contained in:
Jorge Martin Espinosa 2025-05-26 17:10:20 +02:00 committed by GitHub
parent f0c9f8294a
commit f455085e08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 882 additions and 523 deletions

View file

@ -13,16 +13,13 @@ import io.element.android.libraries.matrix.api.notification.NotificationData
import io.element.android.libraries.matrix.api.notification.NotificationService
class FakeNotificationService : NotificationService {
private var getNotificationResult: Result<NotificationData?> = Result.success(null)
private var getNotificationsResult: Result<Map<EventId, NotificationData>> = Result.success(emptyMap())
fun givenGetNotificationResult(result: Result<NotificationData?>) {
getNotificationResult = result
fun givenGetNotificationsResult(result: Result<Map<EventId, NotificationData>>) {
getNotificationsResult = result
}
override suspend fun getNotification(
roomId: RoomId,
eventId: EventId,
): Result<NotificationData?> {
return getNotificationResult
override suspend fun getNotifications(ids: Map<RoomId, List<EventId>>): Result<Map<EventId, NotificationData>> {
return getNotificationsResult
}
}

View file

@ -13,6 +13,7 @@ import io.element.android.libraries.matrix.api.notification.NotificationData
import io.element.android.libraries.matrix.test.AN_EVENT_ID
import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_ROOM_NAME
import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.A_TIMESTAMP
import io.element.android.libraries.matrix.test.A_USER_NAME_2
@ -27,6 +28,7 @@ fun aNotificationData(
roomDisplayName: String? = A_ROOM_NAME
): NotificationData {
return NotificationData(
sessionId = A_SESSION_ID,
eventId = AN_EVENT_ID,
threadId = threadId,
roomId = A_ROOM_ID,