From 2a0ea1eac832f5d9c6cb2c1c5ddd3156527b9fd4 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 25 Sep 2024 15:39:20 +0200 Subject: [PATCH] timeline : makes sure to emit empty list if initial reset has no item. --- .../matrix/impl/timeline/TimelineItemsSubscriber.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt index 5e9c6ac37a..f90f866375 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt @@ -80,10 +80,14 @@ internal class TimelineItemsSubscriber( } private suspend fun postItems(items: List) = coroutineScope { - // Split the initial items in multiple list as there is no pagination in the cached data, so we can post timelineItems asap. - items.chunked(INITIAL_MAX_SIZE).reversed().forEach { - ensureActive() - timelineDiffProcessor.postItems(it) + if (items.isEmpty()) { + timelineDiffProcessor.postItems(emptyList()) + } else { + // Split the initial items in multiple list as there is no pagination in the cached data, so we can post timelineItems asap. + items.chunked(INITIAL_MAX_SIZE).reversed().forEach { + ensureActive() + timelineDiffProcessor.postItems(it) + } } isTimelineInitialized.value = true initLatch.complete(Unit)