mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Add chunk operator on flow
This commit is contained in:
+6
-2
@@ -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)
|
||||
|
||||
|
||||
+7
-3
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user