From ef597cc67a57d2310183009e3e789ea01266395c Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 3 Jul 2019 14:47:33 +0200 Subject: [PATCH] RoomSummary: set unreadNotification to 0 by default --- .../internal/session/room/RoomSummaryUpdater.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt index 766e13fa83..76f2d1516c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt @@ -61,9 +61,8 @@ internal class RoomSummaryUpdater @Inject constructor(private val credentials: C membership: Membership? = null, roomSummary: RoomSyncSummary? = null, unreadNotifications: RoomSyncUnreadNotifications? = null) { - val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst() - ?: realm.createObject(roomId) + ?: realm.createObject(roomId) if (roomSummary != null) { if (roomSummary.heroes.isNotEmpty()) { @@ -77,12 +76,9 @@ internal class RoomSummaryUpdater @Inject constructor(private val credentials: C roomSummaryEntity.joinedMembersCount = roomSummary.joinedMembersCount } } - if (unreadNotifications?.highlightCount != null) { - roomSummaryEntity.highlightCount = unreadNotifications.highlightCount - } - if (unreadNotifications?.notificationCount != null) { - roomSummaryEntity.notificationCount = unreadNotifications.notificationCount - } + roomSummaryEntity.highlightCount = unreadNotifications?.highlightCount ?: 0 + roomSummaryEntity.notificationCount = unreadNotifications?.notificationCount ?:0 + if (membership != null) { roomSummaryEntity.membership = membership }