1
0
mirror of https://github.com/vector-im/riotX-android synced 2025-10-06 00:02:48 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Valere
52f4299a0f Fix back pagination conduit 2022-02-05 17:55:55 +01:00
3 changed files with 15 additions and 3 deletions

1
changelog.d/5166.bugfix Normal file
View File

@@ -0,0 +1 @@
Back pagination not working on conduit

View File

@@ -24,5 +24,5 @@ internal interface TokenChunkEvent {
val events: List<Event>
val stateEvents: List<Event>?
fun hasMore() = start != end
fun hasMore() = end != null && start != end
}

View File

@@ -67,14 +67,25 @@ internal class TokenChunkEventPersistor @Inject constructor(
.awaitTransaction { realm ->
Timber.v("Start persisting ${receivedChunk.events.size} events in $roomId towards $direction")
/**
* As per spec
* if no further events are available (either because we have reached the start of the timeline,
* or because the user does not have permission to see any more events), the end property is omitted from the response.
* Synapse is not omitting it and EA was relying on it
*/
val chunkEnd = if (receivedChunk.events.isEmpty()) {
receivedChunk.start
} else {
receivedChunk.end
}
val nextToken: String?
val prevToken: String?
if (direction == PaginationDirection.FORWARDS) {
nextToken = receivedChunk.end
nextToken = chunkEnd
prevToken = receivedChunk.start
} else {
nextToken = receivedChunk.start
prevToken = receivedChunk.end
prevToken = chunkEnd
}
val existingChunk = ChunkEntity.find(realm, roomId, prevToken = prevToken, nextToken = nextToken)