diff --git a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt index 50e8193..13d26a1 100644 --- a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt +++ b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt @@ -67,9 +67,11 @@ class NotificationFactory( fun createSummary(notifications: List): AndroidNotification { val summaryInboxStyle = notificationStyleFactory.summary(notifications) val openAppIntent = intentFactory.notificationOpenApp(context) + val mostRecent = notifications.mostRecent() return AndroidNotification( - channelId = notifications.mostRecent().summaryChannelId, + channelId = mostRecent.summaryChannelId, messageStyle = summaryInboxStyle, + whenTimestamp = mostRecent.notification.whenTimestamp, alertMoreThanOnce = notifications.any { it.isAlerting }, smallIcon = R.drawable.ic_notification_small_icon, contentIntent = openAppIntent, diff --git a/features/notifications/src/test/kotlin/app/dapk/st/notifications/NotificationFactoryTest.kt b/features/notifications/src/test/kotlin/app/dapk/st/notifications/NotificationFactoryTest.kt index 0c466b6..60d5e0e 100644 --- a/features/notifications/src/test/kotlin/app/dapk/st/notifications/NotificationFactoryTest.kt +++ b/features/notifications/src/test/kotlin/app/dapk/st/notifications/NotificationFactoryTest.kt @@ -60,7 +60,7 @@ class NotificationFactoryTest { val result = notificationFactory.createSummary(notifications) - result shouldBeEqualTo expectedSummary(channelId = A_CHANNEL_ID, shouldAlertMoreThanOnce = true) + result shouldBeEqualTo expectedSummary(notifications.first().notification, shouldAlertMoreThanOnce = true) } @Test @@ -76,7 +76,7 @@ class NotificationFactoryTest { val result = notificationFactory.createSummary(notifications) - result shouldBeEqualTo expectedSummary(channelId = A_CHANNEL_ID, shouldAlertMoreThanOnce = false) + result shouldBeEqualTo expectedSummary(notifications.first().notification, shouldAlertMoreThanOnce = false) } @Test @@ -158,8 +158,9 @@ class NotificationFactoryTest { summaryChannelId = channel, ) - private fun expectedSummary(channelId: String, shouldAlertMoreThanOnce: Boolean) = AndroidNotification( - channelId = channelId, + private fun expectedSummary(notification: AndroidNotification, shouldAlertMoreThanOnce: Boolean) = AndroidNotification( + channelId = notification.channelId, + whenTimestamp = notification.whenTimestamp, messageStyle = A_NOTIFICATION_STYLE, alertMoreThanOnce = shouldAlertMoreThanOnce, smallIcon = R.drawable.ic_notification_small_icon,