From 9f13a9df5499cc19b61eb6445aacbebe5a37ae54 Mon Sep 17 00:00:00 2001 From: David Langley Date: Tue, 4 Jan 2022 12:20:56 +0000 Subject: [PATCH] If latestPreviewableEvent is null we should return false(no messages in room). --- changelog.d/4749.bugfix | 1 + .../sdk/internal/session/room/summary/RoomSummaryUpdater.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/4749.bugfix diff --git a/changelog.d/4749.bugfix b/changelog.d/4749.bugfix new file mode 100644 index 0000000000..5ea29f66a0 --- /dev/null +++ b/changelog.d/4749.bugfix @@ -0,0 +1 @@ +Fix for broken unread message indicator on the room list when there are no messages in the room. \ No newline at end of file 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 3556cabb33..f3ff38e237 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 @@ -136,7 +136,7 @@ internal class RoomSummaryUpdater @Inject constructor( roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0 || // avoid this call if we are sure there are unread events - !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId) + latestPreviewableEvent?.let { !isEventRead(realm.configuration, userId, roomId, it.eventId) } ?: false roomSummaryEntity.setDisplayName(roomDisplayNameResolver.resolve(realm, roomId)) roomSummaryEntity.avatarUrl = roomAvatarResolver.resolve(realm, roomId)