mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
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
This commit is contained in:
committed by
GitHub
parent
d826a72d49
commit
7fd8e5b721
+3
-6
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user