mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-06 00:02:48 +02:00
Fix back pagination conduit
This commit is contained in:
1
changelog.d/5166.bugfix
Normal file
1
changelog.d/5166.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Back pagination not working on conduit
|
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user