Timeline: exposes simple request for backward pagination
This commit is contained in:
parent
891c05a99c
commit
449c331879
4 changed files with 18 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ interface MatrixTimeline : AutoCloseable {
|
|||
val paginationState: StateFlow<PaginationState>
|
||||
val timelineItems: Flow<List<MatrixTimelineItem>>
|
||||
|
||||
suspend fun paginateBackwards(requestSize: Int): Result<Unit>
|
||||
suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result<Unit>
|
||||
suspend fun fetchDetailsForEvent(eventId: EventId): Result<Unit>
|
||||
suspend fun sendReadReceipt(eventId: EventId): Result<Unit>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ class AsyncMatrixTimeline(
|
|||
override val paginationState: StateFlow<MatrixTimeline.PaginationState> = _paginationState
|
||||
override val timelineItems: Flow<List<MatrixTimelineItem>> = _timelineItems
|
||||
|
||||
override suspend fun paginateBackwards(requestSize: Int): Result<Unit> {
|
||||
return timeline.await().paginateBackwards(requestSize)
|
||||
}
|
||||
|
||||
override suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result<Unit> {
|
||||
return timeline.await().paginateBackwards(requestSize, untilNumberOfItems)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,14 @@ class RustMatrixTimeline(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun paginateBackwards(requestSize: Int): Result<Unit> {
|
||||
val paginationOptions = PaginationOptions.SimpleRequest(
|
||||
eventLimit = requestSize.toUShort(),
|
||||
waitForToken = true,
|
||||
)
|
||||
return paginateBackwards(paginationOptions)
|
||||
}
|
||||
|
||||
override suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result<Unit> {
|
||||
val paginationOptions = PaginationOptions.UntilNumItems(
|
||||
eventLimit = requestSize.toUShort(),
|
||||
|
|
@ -198,6 +206,7 @@ class RustMatrixTimeline(
|
|||
}
|
||||
|
||||
private suspend fun paginateBackwards(paginationOptions: PaginationOptions): Result<Unit> = withContext(dispatcher) {
|
||||
initLatch.await()
|
||||
runCatching {
|
||||
if (!canBackPaginate()) throw TimelineException.CannotPaginate
|
||||
Timber.v("Start back paginating for room ${matrixRoom.roomId} ")
|
||||
|
|
|
|||
|
|
@ -56,7 +56,10 @@ class FakeMatrixTimeline(
|
|||
|
||||
override val timelineItems: Flow<List<MatrixTimelineItem>> = _timelineItems
|
||||
|
||||
override suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result<Unit> {
|
||||
override suspend fun paginateBackwards(requestSize: Int) = paginateBackwards()
|
||||
override suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int) = paginateBackwards()
|
||||
|
||||
private suspend fun paginateBackwards(): Result<Unit> {
|
||||
updatePaginationState {
|
||||
copy(isBackPaginating = true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue