Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix back pagination conduit #5168

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5166.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Back pagination not working on conduit
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking events.is_empty is wrong here. There may be events, but if those are the 'last' events in the room, 'end' will not be set.

receivedChunk.start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReceivedChunk.start should be the same as the from param, so we will be blocked too, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 'start' is set but 'end' is unset (=null?). Probably chunkEnd=null causes these problems in Element Android

} 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)
Expand Down