Pagination : avoid breaking timeline when paginating twice from same token (race condition)

This commit is contained in:
ganfra 2019-07-09 14:44:59 +02:00
parent 8777d13d8b
commit b5650b2b8f

View File

@ -128,6 +128,12 @@ internal class TokenChunkEventPersistor @Inject constructor(private val monarchy
nextToken = receivedChunk.start
prevToken = receivedChunk.end
}
if (ChunkEntity.find(realm, roomId, nextToken = nextToken) != null || ChunkEntity.find(realm, roomId, prevToken = prevToken) != null) {
Timber.v("Already inserted - SKIP")
return@tryTransactionSync
}
val prevChunk = ChunkEntity.find(realm, roomId, nextToken = prevToken)
val nextChunk = ChunkEntity.find(realm, roomId, prevToken = nextToken)