Attempt to fix room list item duplicates at midnight (#6793)

* Attempt to fix room list item duplicates at midnight

This seems to happen because of a race condition between `RoomListDataSource.observeDateTimeChanges` and `RoomListDataSource.replaceWith` being called at almost the same time and the first one using the newly received items from observing the timeline items but not updating the cache which will be later reused by `replaceWith`, containing incorrect indices
This commit is contained in:
Jorge Martin Espinosa 2026-05-18 22:18:52 +02:00 committed by GitHub
parent c2ec69e1c9
commit 603c4feda1
2 changed files with 66 additions and 2 deletions

View file

@ -83,8 +83,8 @@ class RoomListDataSource(
val loadingState = roomList.loadingState
fun launchIn(coroutineScope: CoroutineScope) {
roomList
fun launchIn(coroutineScope: CoroutineScope): Job {
return roomList
.summaries
.onEach { roomSummaries ->
replaceWith(roomSummaries)
@ -212,6 +212,7 @@ class RoomListDataSource(
private suspend fun rebuildAllRoomSummaries() {
lock.withLock {
roomList.summaries.replayCache.firstOrNull()?.let { roomSummaries ->
diffCacheUpdater.updateWith(roomSummaries)
buildAndEmitAllRooms(roomSummaries, useCache = false)
}
}