Skip to content

Commit fdd0a0d

Browse files
authored
Merge pull request #3538 from element-hq/feature/fga/timeline_emit_empty_list
timeline : makes sure to emit empty list if initial reset has no item.
2 parents 14dc0da + db569cb commit fdd0a0d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ internal class TimelineItemsSubscriber(
8080
}
8181

8282
private suspend fun postItems(items: List<TimelineItem>) = coroutineScope {
83-
// Split the initial items in multiple list as there is no pagination in the cached data, so we can post timelineItems asap.
84-
items.chunked(INITIAL_MAX_SIZE).reversed().forEach {
85-
ensureActive()
86-
timelineDiffProcessor.postItems(it)
83+
if (items.isEmpty()) {
84+
// Makes sure to post empty list if there is no item, so you can handle empty state.
85+
timelineDiffProcessor.postItems(emptyList())
86+
} else {
87+
// Split the initial items in multiple list as there is no pagination in the cached data, so we can post timelineItems asap.
88+
items.chunked(INITIAL_MAX_SIZE).reversed().forEach {
89+
ensureActive()
90+
timelineDiffProcessor.postItems(it)
91+
}
8792
}
8893
isTimelineInitialized.value = true
8994
initLatch.complete(Unit)

0 commit comments

Comments
 (0)