Timeline: split the initial item list in small chunks to post items asap
This commit is contained in:
parent
635e9b9edd
commit
9784d8c874
1 changed files with 5 additions and 1 deletions
|
|
@ -44,6 +44,7 @@ import org.matrix.rustcomponents.sdk.TimelineItem
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
|
||||||
|
private const val INITIAL_MAX_SIZE = 50
|
||||||
|
|
||||||
class RustMatrixTimeline(
|
class RustMatrixTimeline(
|
||||||
roomCoroutineScope: CoroutineScope,
|
roomCoroutineScope: CoroutineScope,
|
||||||
|
|
@ -84,7 +85,10 @@ class RustMatrixTimeline(
|
||||||
override val timelineItems: Flow<List<MatrixTimelineItem>> = _timelineItems.sample(50)
|
override val timelineItems: Flow<List<MatrixTimelineItem>> = _timelineItems.sample(50)
|
||||||
|
|
||||||
internal suspend fun postItems(items: List<TimelineItem>) {
|
internal suspend fun postItems(items: List<TimelineItem>) {
|
||||||
timelineDiffProcessor.postItems(items)
|
// 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 {
|
||||||
|
timelineDiffProcessor.postItems(it)
|
||||||
|
}
|
||||||
isInit.set(true)
|
isInit.set(true)
|
||||||
initLatch.complete(Unit)
|
initLatch.complete(Unit)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue