From 52d0da705316328499bc33abd2b3c6f917faf45c Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 3 Nov 2021 19:02:44 +0100 Subject: [PATCH] Timeline: remove previous lastForward chunk --- .../session/sync/handler/room/RoomSyncHandler.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt index 8c4af81c99..4a3a3617ca 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt @@ -344,15 +344,17 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle syncLocalTimestampMillis: Long, aggregator: SyncResponsePostTreatmentAggregator): ChunkEntity { val lastChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomEntity.roomId) + if (isLimited && lastChunk != null) { + lastChunk.deleteOnCascade(deleteStateEvents = true, canDeleteRoot = true) + } val chunkEntity = if (!isLimited && lastChunk != null) { lastChunk } else { - realm.createObject().apply { this.prevToken = prevToken } + realm.createObject().apply { + this.prevToken = prevToken + this.isLastForward = true + } } - // Only one chunk has isLastForward set to true - lastChunk?.isLastForward = false - chunkEntity.isLastForward = true - val eventIds = ArrayList(eventList.size) val roomMemberContentsByUser = HashMap()