From f50b21d9b70af3c586c9aa78d9d3e42d6042af58 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 31 Mar 2022 08:37:40 +0200 Subject: [PATCH] Do not clear unread counts when fetching room members This messes with our "open without reading" functionality. Change-Id: Ie1bf84aa79b3bc0c18efd7325f817aa227b8e748 --- .../room/membership/LoadRoomMembersTask.kt | 2 +- .../session/room/summary/RoomSummaryUpdater.kt | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt index 3d0f51b831..15e804d69e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt @@ -126,7 +126,7 @@ internal class DefaultLoadRoomMembersTask @Inject constructor( roomMemberEventHandler.handle(realm, roomId, roomMemberEvent) } roomEntity.membersLoadStatus = RoomMembersLoadStatusType.LOADED - roomSummaryUpdater.update(realm, roomId, updateMembers = true) + roomSummaryUpdater.update(realm, roomId, updateMembers = true, updateCounts = false) } if (cryptoSessionInfoProvider.isRoomEncrypted(roomId)) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt index 4b8cef3691..7cf98549eb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt @@ -87,7 +87,8 @@ internal class RoomSummaryUpdater @Inject constructor( unreadNotifications: RoomSyncUnreadNotifications? = null, unreadCount: Int? = null, updateMembers: Boolean = false, - inviterId: String? = null) { + inviterId: String? = null, + updateCounts: Boolean = true) { val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId) if (roomSummary != null) { if (roomSummary.heroes.isNotEmpty()) { @@ -101,11 +102,13 @@ internal class RoomSummaryUpdater @Inject constructor( roomSummaryEntity.joinedMembersCount = roomSummary.joinedMembersCount } } - roomSummaryEntity.highlightCount = unreadNotifications?.highlightCount ?: 0 - roomSummaryEntity.notificationCount = unreadNotifications?.notificationCount ?: 0 - roomSummaryEntity.unreadCount = unreadCount - roomSummaryEntity.aggregatedNotificationCount = roomSummaryEntity.notificationCount - roomSummaryEntity.aggregatedUnreadCount = roomSummaryEntity.safeUnreadCount() + if (updateCounts) { + roomSummaryEntity.highlightCount = unreadNotifications?.highlightCount ?: 0 + roomSummaryEntity.notificationCount = unreadNotifications?.notificationCount ?: 0 + roomSummaryEntity.unreadCount = unreadCount + roomSummaryEntity.aggregatedNotificationCount = roomSummaryEntity.notificationCount + roomSummaryEntity.aggregatedUnreadCount = roomSummaryEntity.safeUnreadCount() + } if (membership != null) { roomSummaryEntity.membership = membership