From 7fd8e5b7214fcfbcae24ca338c994feec13b63c8 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Fri, 2 Oct 2026 16:36:22 +0200 Subject: [PATCH] Fix unread indicator for messages (#7841) * The expected logic for unread messages is displaying just a dot The count might not be accurate, so we keep the dot for now. * Fix tests --- .../features/home/impl/components/RoomSummaryRow.kt | 9 +++------ .../components/RoomSummaryRowUnreadIndicatorCountTest.kt | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/components/RoomSummaryRow.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/components/RoomSummaryRow.kt index 1033d7a494..2ab529ed43 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/components/RoomSummaryRow.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/components/RoomSummaryRow.kt @@ -391,14 +391,11 @@ internal fun RoomListRoomSummary.unreadIndicatorCount( val isMuted = userDefinedNotificationMode == RoomNotificationMode.MUTE return when { // Show only unread notifications when the room is not muted and there are unread notifications - !isMuted && numberOfUnreadNotifications > 0 -> numberOfUnreadNotifications - // Otherwise, show unread messages when showAllActivity is true - showAllActivity -> numberOfUnreadMessages.takeIf { it > 0 } + !isMuted && numberOfUnreadNotifications > 0 -> if (showUnreadCount) numberOfUnreadNotifications else 0 + // Otherwise, show a dot for unread messages when showAllActivity is true and there are unread messages + showAllActivity -> if (numberOfUnreadMessages > 0) 0 else null // Or don't display anything else -> null - }?.let { - // We only want to show the count if the option is enabled, otherwise we just show the dot indicator (value 0) - if (showUnreadCount) it else 0 } } diff --git a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/components/RoomSummaryRowUnreadIndicatorCountTest.kt b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/components/RoomSummaryRowUnreadIndicatorCountTest.kt index 07060c11ab..5b4d918ee9 100644 --- a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/components/RoomSummaryRowUnreadIndicatorCountTest.kt +++ b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/components/RoomSummaryRowUnreadIndicatorCountTest.kt @@ -34,12 +34,12 @@ class RoomSummaryRowUnreadIndicatorCountTest { } @Test - fun `unread messages are used when there are no unread notifications and showAllActivity is true`() { + fun `unread messages are used when there are no unread notifications and showAllActivity is true, but always display a dot`() { val room = createRoomListRoomSummary( numberOfUnreadNotifications = 0, numberOfUnreadMessages = 5, ) - assertThat(room.unreadIndicatorCount(showUnreadCount = true, showAllActivity = true)).isEqualTo(5L) + assertThat(room.unreadIndicatorCount(showUnreadCount = true, showAllActivity = true)).isEqualTo(0L) assertThat(room.unreadIndicatorCount(showUnreadCount = false, showAllActivity = true)).isEqualTo(0L) } @@ -54,13 +54,13 @@ class RoomSummaryRowUnreadIndicatorCountTest { } @Test - fun `muted room ignores unread notifications and falls back to unread messages when showAllActivity is true`() { + fun `muted room ignores unread notifications and falls back to unread messages displaying a dot when showAllActivity is true`() { val room = createRoomListRoomSummary( numberOfUnreadNotifications = 3, numberOfUnreadMessages = 5, userDefinedNotificationMode = RoomNotificationMode.MUTE, ) - assertThat(room.unreadIndicatorCount(showUnreadCount = true, showAllActivity = true)).isEqualTo(5L) + assertThat(room.unreadIndicatorCount(showUnreadCount = true, showAllActivity = true)).isEqualTo(0L) assertThat(room.unreadIndicatorCount(showUnreadCount = false, showAllActivity = true)).isEqualTo(0L) assertThat(room.unreadIndicatorCount(showUnreadCount = true, showAllActivity = false)).isNull() }