Fix another case of missing read markers

HasUnread might not be correct on the first try while loading the
timeline.

Change-Id: I6bba6cc58ca21725764d41909deb9a0495d51ea0
This commit is contained in:
SpiritCroc 2022-03-09 13:43:52 +01:00
parent df0b5ca0a0
commit 4f2931feae

View file

@ -1132,10 +1132,12 @@ 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
current is UnreadState.HasUnread /*|| current is UnreadState.HasNoUnread */ -> true
previous is UnreadState.HasUnread && current is UnreadState.HasUnread -> false
current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true
else -> false
}
}