From e6fab7eee26e41270045888ec0c4ecfaeca4a9c4 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Fri, 31 May 2024 10:16:59 +0200 Subject: [PATCH] Fix grouped notifications only displaying the latest message (#2956) `DefaultActiveNotificationsProvider.getNotificationsForSession(sessionId)` had a broken logic for checking a notification's group and retrieving notifications from the same session. --- .../push/impl/notifications/ActiveNotificationsProvider.kt | 2 +- .../notifications/DefaultActiveNotificationsProviderTest.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt index c4814d8134..0746e9c5cd 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt @@ -44,7 +44,7 @@ class DefaultActiveNotificationsProvider @Inject constructor( } override fun getNotificationsForSession(sessionId: SessionId): List { - return notificationManager.activeNotifications.filter { it.groupKey == sessionId.value } + return notificationManager.activeNotifications.filter { it.notification.group == sessionId.value } } override fun getMembershipNotificationForSession(sessionId: SessionId): List { diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt index 31daf9e4cc..6f40534335 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt @@ -16,8 +16,10 @@ package io.element.android.libraries.push.impl.notifications +import android.app.Notification import android.service.notification.StatusBarNotification import androidx.core.app.NotificationManagerCompat +import androidx.test.platform.app.InstrumentationRegistry import com.google.common.truth.Truth.assertThat import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.libraries.matrix.test.A_ROOM_ID_2 @@ -157,8 +159,8 @@ class DefaultActiveNotificationsProviderTest { private fun aStatusBarNotification(id: Int, groupId: String, tag: String? = null) = mockk { every { this@mockk.id } returns id - every { this@mockk.groupKey } returns groupId every { this@mockk.tag } returns tag + every { this@mockk.notification } returns Notification.Builder(InstrumentationRegistry.getInstrumentation().targetContext).setGroup(groupId).build() } private fun createActiveNotificationsProvider(