diff --git a/changelog.d/5564.bugfix b/changelog.d/5564.bugfix new file mode 100644 index 0000000000..64891b503c --- /dev/null +++ b/changelog.d/5564.bugfix @@ -0,0 +1 @@ +Fix sometimes read marker not properly updating diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt index 8a7078fdf9..c8f2132ae6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt @@ -83,11 +83,15 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity, isLastBackward.set(chunkEntity.isLastBackward) } if (changeSet.isFieldChanged(ChunkEntityFields.NEXT_CHUNK.`$`)) { - nextChunk = createTimelineChunk(chunkEntity.nextChunk) + nextChunk = createTimelineChunk(chunkEntity.nextChunk).also { + it?.prevChunk = this + } nextChunkLatch?.complete(Unit) } if (changeSet.isFieldChanged(ChunkEntityFields.PREV_CHUNK.`$`)) { - prevChunk = createTimelineChunk(chunkEntity.prevChunk) + prevChunk = createTimelineChunk(chunkEntity.prevChunk).also { + it?.nextChunk = this + } prevChunkLatch?.complete(Unit) } } @@ -194,7 +198,9 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity, when { nextChunkEntity != null -> { if (nextChunk == null) { - nextChunk = createTimelineChunk(nextChunkEntity) + nextChunk = createTimelineChunk(nextChunkEntity).also { + it?.prevChunk = this + } } nextChunk?.loadMore(offsetCount, direction, fetchFromServerIfNeeded) ?: LoadMoreResult.FAILURE } @@ -210,7 +216,9 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity, when { prevChunkEntity != null -> { if (prevChunk == null) { - prevChunk = createTimelineChunk(prevChunkEntity) + prevChunk = createTimelineChunk(prevChunkEntity).also { + it?.nextChunk = this + } } prevChunk?.loadMore(offsetCount, direction, fetchFromServerIfNeeded) ?: LoadMoreResult.FAILURE }