RoomSummary: set unreadNotification to 0 by default

This commit is contained in:
ganfra 2019-07-03 14:47:33 +02:00
parent 39070820be
commit ef597cc67a
1 changed files with 4 additions and 8 deletions

View File

@ -61,9 +61,8 @@ internal class RoomSummaryUpdater @Inject constructor(private val credentials: C
membership: Membership? = null, membership: Membership? = null,
roomSummary: RoomSyncSummary? = null, roomSummary: RoomSyncSummary? = null,
unreadNotifications: RoomSyncUnreadNotifications? = null) { unreadNotifications: RoomSyncUnreadNotifications? = null) {
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst() val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
?: realm.createObject(roomId) ?: realm.createObject(roomId)
if (roomSummary != null) { if (roomSummary != null) {
if (roomSummary.heroes.isNotEmpty()) { if (roomSummary.heroes.isNotEmpty()) {
@ -77,12 +76,9 @@ internal class RoomSummaryUpdater @Inject constructor(private val credentials: C
roomSummaryEntity.joinedMembersCount = roomSummary.joinedMembersCount roomSummaryEntity.joinedMembersCount = roomSummary.joinedMembersCount
} }
} }
if (unreadNotifications?.highlightCount != null) { roomSummaryEntity.highlightCount = unreadNotifications?.highlightCount ?: 0
roomSummaryEntity.highlightCount = unreadNotifications.highlightCount roomSummaryEntity.notificationCount = unreadNotifications?.notificationCount ?:0
}
if (unreadNotifications?.notificationCount != null) {
roomSummaryEntity.notificationCount = unreadNotifications.notificationCount
}
if (membership != null) { if (membership != null) {
roomSummaryEntity.membership = membership roomSummaryEntity.membership = membership
} }