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.
This commit is contained in:
Jorge Martin Espinosa
2024-05-31 10:16:59 +02:00
committed by GitHub
parent 155fd4ab81
commit e6fab7eee2
2 changed files with 4 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ class DefaultActiveNotificationsProvider @Inject constructor(
}
override fun getNotificationsForSession(sessionId: SessionId): List<StatusBarNotification> {
return notificationManager.activeNotifications.filter { it.groupKey == sessionId.value }
return notificationManager.activeNotifications.filter { it.notification.group == sessionId.value }
}
override fun getMembershipNotificationForSession(sessionId: SessionId): List<StatusBarNotification> {

View File

@@ -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<StatusBarNotification> {
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(