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.

Change-Id: Idf0f1882ec4f197f58f3818e63386a4def838b25
This commit is contained in:
SpiritCroc 2022-03-18 07:59:32 +01:00
parent 0d43fc6861
commit ab9caef466

View file

@ -108,8 +108,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 {