Fix another case of missing read markers

HasUnread might not be correct on the first try while loading the
timeline.
This commit is contained in:
SpiritCroc 2022-03-09 13:43:52 +01:00
parent 8efd389a3c
commit 1206c31e3a
1 changed files with 2 additions and 0 deletions

View File

@ -1099,9 +1099,11 @@ class TimelineViewModel @AssistedInject constructor(
computeUnreadState(timelineEvents, roomSummary)
}
// We don't want live update of unread so we skip when we already had a HasUnread or HasNoUnread
// However, we want to update an existing HasUnread, as we might get additional information during loading of events.
.distinctUntilChanged { previous, current ->
when {
previous is UnreadState.Unknown || previous is UnreadState.ReadMarkerNotLoaded -> false
previous is UnreadState.HasUnread && current is UnreadState.HasUnread -> false
current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true
else -> false
}