Only show HasUnread -> HasUnread updates for same readMarker

Change-Id: Id4c3bb55a7cfcfc97bc362c64213c2c165a24ab3
This commit is contained in:
SpiritCroc 2022-03-21 11:23:10 +01:00
parent ece413887a
commit 47a47a9e97
2 changed files with 4 additions and 3 deletions

View File

@ -37,7 +37,7 @@ sealed class UnreadState {
object Unknown : UnreadState()
object HasNoUnread : UnreadState()
data class ReadMarkerNotLoaded(val readMarkerId: String) : UnreadState()
data class HasUnread(val firstUnreadEventId: String) : UnreadState()
data class HasUnread(val firstUnreadEventId: String, val readMarkerId: String) : UnreadState()
}
data class JitsiState(

View File

@ -1134,7 +1134,8 @@ class TimelineViewModel @AssistedInject constructor(
.distinctUntilChanged { previous, current ->
when {
previous is UnreadState.Unknown || previous is UnreadState.ReadMarkerNotLoaded -> false
previous is UnreadState.HasUnread && current is UnreadState.HasUnread -> false
previous is UnreadState.HasUnread && current is UnreadState.HasUnread &&
previous.readMarkerId == current.readMarkerId -> false
current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true
else -> false
}
@ -1168,7 +1169,7 @@ class TimelineViewModel @AssistedInject constructor(
val isFromMe = timelineEvent.root.senderId == session.myUserId
rmDimber.i{"isFromMe = $isFromMe"}
if (!isFromMe) {
return UnreadState.HasUnread(eventId)
return UnreadState.HasUnread(eventId, readMarkerIdSnapshot)
}
}
rmDimber.i{"hasNoUnread / firstDisplayableEventIndex: $firstDisplayableEventIndex / " +