Browse Source

timeline : makes sure to emit empty list if initial reset has no item.

pull/3538/head
ganfra 3 weeks ago
parent
commit
db569cbcbe
  1. 13
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriber.kt

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

@ -80,10 +80,15 @@ internal class TimelineItemsSubscriber(
} }
private suspend fun postItems(items: List<TimelineItem>) = coroutineScope { private suspend fun postItems(items: List<TimelineItem>) = coroutineScope {
// Split the initial items in multiple list as there is no pagination in the cached data, so we can post timelineItems asap. if (items.isEmpty()) {
items.chunked(INITIAL_MAX_SIZE).reversed().forEach { // Makes sure to post empty list if there is no item, so you can handle empty state.
ensureActive() timelineDiffProcessor.postItems(emptyList())
timelineDiffProcessor.postItems(it) } 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 isTimelineInitialized.value = true
initLatch.complete(Unit) initLatch.complete(Unit)

Loading…
Cancel
Save