TokenChunkEventPersistor: always link all matching chunks

The previous fix only works around the issue when it is detected. This
may require re-entering the room once when it gets stuck. If we ensure
proper linking from the beginning, hopefully we don't run into any
issues at all.
This commit is contained in:
SpiritCroc 2022-03-18 07:59:32 +01:00
parent 682f4c35d2
commit 6878a973ed

View file

@ -109,8 +109,14 @@ internal class TokenChunkEventPersistor @Inject constructor(
this.nextChunk = nextChunk
this.prevChunk = prevChunk
}
nextChunk?.prevChunk = currentChunk
prevChunk?.nextChunk = currentChunk
val allNextChunks = ChunkEntity.findAll(realm, roomId, prevToken = nextToken)
val allPrevChunks = ChunkEntity.findAll(realm, roomId, nextToken = prevToken)
allNextChunks?.forEach {
it.prevChunk = currentChunk
}
allPrevChunks?.forEach {
it.nextChunk = currentChunk
}
if (receivedChunk.events.isEmpty() && !receivedChunk.hasMore()) {
handleReachEnd(roomId, direction, currentChunk)
} else {