Restore old hasUnread detection algorithm to include notices

Change-Id: Ib934a381cad1fec18815e222d61350240ba9d93f
This commit is contained in:
SpiritCroc 2021-09-25 10:14:03 +02:00
parent 3563e76432
commit 45c6a4e9ba

View file

@ -137,18 +137,16 @@ internal class RoomSummaryUpdater @Inject constructor(
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
}
// If unreadCount == null, the server likely just doesn't support MSC 2654, so we need to check manually either way
val hasUnreadEvents = unreadCount == null || unreadCount > 0
roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0
// avoid this call if we are sure there are (no) unread events
|| (hasUnreadEvents && !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId))
// avoid this call if we are sure there are unread events
|| !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId)
roomSummaryEntity.hasUnreadContentMessages = roomSummaryEntity.notificationCount > 0
// avoid this call if we are sure there are (no) unread events
|| (hasUnreadEvents && latestPreviewableContentEvent != null
&& !isEventRead(realm.configuration, userId, roomId, latestPreviewableContentEvent.eventId))
// avoid this call if we are sure there are unread events
|| (latestPreviewableContentEvent != null
&& !isEventRead(realm.configuration, userId, roomId, latestPreviewableContentEvent.eventId))
roomSummaryEntity.hasUnreadOriginalContentMessages = roomSummaryEntity.notificationCount > 0
// avoid this call if we are sure there are (no) unread events
|| (hasUnreadEvents && latestPreviewableOriginalContentEvent != null
// avoid this call if we are sure there are unread events
|| (latestPreviewableOriginalContentEvent != null
&& !isEventRead(realm.configuration, userId, roomId, latestPreviewableOriginalContentEvent.eventId))
roomSummaryEntity.displayName = roomDisplayNameResolver.resolve(realm, roomId)