mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 11:48:51 +03:00
Rely on MSC2654 unread counts when available for detecting unread status
Previously, we were doing some hybrid approach, in order to take into account the room preview settings. However, this can mark chats as unread in cases where isEventRead() does guessing due to insufficient events loaded. Just using the counts when possible is more reliable. Change-Id: I22dc242e69f1946c039d0b4f81851c6b0c0556e2
This commit is contained in:
parent
200370912a
commit
d1ee0dea6b
1 changed files with 20 additions and 12 deletions
|
@ -160,18 +160,26 @@ internal class RoomSummaryUpdater @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
roomSummaryEntity.hasUnreadContentMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableContentEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
roomSummaryEntity.hasUnreadOriginalContentMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableOriginalContentEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
val roomSummaryUnreadCount = roomSummaryEntity.unreadCount
|
||||
if (roomSummaryUnreadCount != null /* && preferences.prioritizeUnreadCountsOverRoomPreviewsForUnreadCalculation() */) {
|
||||
val hasUnreadMessages = roomSummaryUnreadCount > 0
|
||||
roomSummaryEntity.hasUnreadMessages = hasUnreadMessages
|
||||
roomSummaryEntity.hasUnreadContentMessages = hasUnreadMessages
|
||||
roomSummaryEntity.hasUnreadOriginalContentMessages = hasUnreadMessages
|
||||
} else {
|
||||
roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
//(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
roomSummaryEntity.hasUnreadContentMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
//(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableContentEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
roomSummaryEntity.hasUnreadOriginalContentMessages = roomSummaryEntity.notificationCount > 0 ||
|
||||
//(roomSummaryEntity.unreadCount?.let { it > 0 } ?: false) ||
|
||||
// avoid this call if we are sure there are unread events
|
||||
latestPreviewableOriginalContentEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false
|
||||
}
|
||||
|
||||
roomSummaryEntity.setDisplayName(roomDisplayNameResolver.resolve(realm, roomId))
|
||||
roomSummaryEntity.avatarUrl = roomAvatarResolver.resolve(realm, roomId)
|
||||
|
|
Loading…
Add table
Reference in a new issue