From 99aa9493d6c74aabfe9c489de9fdc06f36ee883a Mon Sep 17 00:00:00 2001 From: Yoan Pintas Date: Wed, 12 Apr 2023 09:18:02 +0200 Subject: [PATCH] Update read marker when we go back in live (#8306) --- .../app/features/home/room/detail/TimelineViewModel.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index b889c808b3..b2b1f1ef36 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -1325,13 +1325,17 @@ 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, if the readMarkerId hasn't changed, + // However, we want to update an existing HasUnread, if the readMarkerId hasn't changed or when we go back in live, // as we might be loading new events to fill gaps in the timeline. .distinctUntilChanged { previous, current -> when { previous is UnreadState.Unknown || previous is UnreadState.ReadMarkerNotLoaded -> false previous is UnreadState.HasUnread && current is UnreadState.HasUnread && previous.readMarkerId == current.readMarkerId -> false + previous is UnreadState.HasUnread && ( + current is UnreadState.HasUnread && previous.firstUnreadEventId != current.firstUnreadEventId || + current is UnreadState.HasNoUnread + ) && timeline?.isLive.orFalse() -> false current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true else -> false }