Add chunk operator on flow
This commit is contained in:
parent
9dfd471907
commit
ef74e54fea
3 changed files with 99 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package io.element.android.x.matrix.room
|
||||
|
||||
import io.element.android.x.core.data.CoroutineDispatchers
|
||||
import io.element.android.x.core.data.flow.chunk
|
||||
import io.element.android.x.matrix.room.message.RoomMessageFactory
|
||||
import io.element.android.x.matrix.sync.roomListDiff
|
||||
import io.element.android.x.matrix.sync.state
|
||||
|
|
@ -34,9 +35,12 @@ internal class RustRoomSummaryDataSource(
|
|||
|
||||
fun startSync(){
|
||||
slidingSyncView.roomListDiff()
|
||||
.onEach { diff ->
|
||||
.chunk(100)
|
||||
.onEach { diffs ->
|
||||
updateRoomSummaries {
|
||||
applyDiff(diff)
|
||||
diffs.forEach {
|
||||
applyDiff(it)
|
||||
}
|
||||
}
|
||||
}.launchIn(coroutineScope)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package io.element.android.x.matrix.timeline
|
||||
|
||||
import io.element.android.x.core.data.CoroutineDispatchers
|
||||
import io.element.android.x.core.data.flow.chunk
|
||||
import io.element.android.x.matrix.core.EventId
|
||||
import io.element.android.x.matrix.room.MatrixRoom
|
||||
import io.element.android.x.matrix.room.timelineDiff
|
||||
|
|
@ -42,9 +43,12 @@ class MatrixTimeline(
|
|||
|
||||
private fun diffFlow(): Flow<Unit> {
|
||||
return room.timelineDiff()
|
||||
.onEach { timelineDiff ->
|
||||
.chunk(100)
|
||||
.onEach { timelineDiffs ->
|
||||
updateTimelineItems {
|
||||
applyDiff(timelineDiff)
|
||||
timelineDiffs.onEach {
|
||||
applyDiff(it)
|
||||
}
|
||||
}
|
||||
}.map { }
|
||||
}
|
||||
|
|
@ -107,7 +111,7 @@ class MatrixTimeline(
|
|||
room.addTimelineListener(timelineListener)
|
||||
}
|
||||
|
||||
fun dispose(){
|
||||
fun dispose() {
|
||||
room.removeTimeline()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue