applying when timestamp to the summary notification

This commit is contained in:
Adam Brown 2022-07-28 22:06:04 +01:00
parent 8c1265c957
commit 3bbfd05fce
2 changed files with 8 additions and 5 deletions

View File

@ -67,9 +67,11 @@ class NotificationFactory(
fun createSummary(notifications: List<NotificationTypes.Room>): AndroidNotification { fun createSummary(notifications: List<NotificationTypes.Room>): AndroidNotification {
val summaryInboxStyle = notificationStyleFactory.summary(notifications) val summaryInboxStyle = notificationStyleFactory.summary(notifications)
val openAppIntent = intentFactory.notificationOpenApp(context) val openAppIntent = intentFactory.notificationOpenApp(context)
val mostRecent = notifications.mostRecent()
return AndroidNotification( return AndroidNotification(
channelId = notifications.mostRecent().summaryChannelId, channelId = mostRecent.summaryChannelId,
messageStyle = summaryInboxStyle, messageStyle = summaryInboxStyle,
whenTimestamp = mostRecent.notification.whenTimestamp,
alertMoreThanOnce = notifications.any { it.isAlerting }, alertMoreThanOnce = notifications.any { it.isAlerting },
smallIcon = R.drawable.ic_notification_small_icon, smallIcon = R.drawable.ic_notification_small_icon,
contentIntent = openAppIntent, contentIntent = openAppIntent,

View File

@ -60,7 +60,7 @@ class NotificationFactoryTest {
val result = notificationFactory.createSummary(notifications) val result = notificationFactory.createSummary(notifications)
result shouldBeEqualTo expectedSummary(channelId = A_CHANNEL_ID, shouldAlertMoreThanOnce = true) result shouldBeEqualTo expectedSummary(notifications.first().notification, shouldAlertMoreThanOnce = true)
} }
@Test @Test
@ -76,7 +76,7 @@ class NotificationFactoryTest {
val result = notificationFactory.createSummary(notifications) val result = notificationFactory.createSummary(notifications)
result shouldBeEqualTo expectedSummary(channelId = A_CHANNEL_ID, shouldAlertMoreThanOnce = false) result shouldBeEqualTo expectedSummary(notifications.first().notification, shouldAlertMoreThanOnce = false)
} }
@Test @Test
@ -158,8 +158,9 @@ class NotificationFactoryTest {
summaryChannelId = channel, summaryChannelId = channel,
) )
private fun expectedSummary(channelId: String, shouldAlertMoreThanOnce: Boolean) = AndroidNotification( private fun expectedSummary(notification: AndroidNotification, shouldAlertMoreThanOnce: Boolean) = AndroidNotification(
channelId = channelId, channelId = notification.channelId,
whenTimestamp = notification.whenTimestamp,
messageStyle = A_NOTIFICATION_STYLE, messageStyle = A_NOTIFICATION_STYLE,
alertMoreThanOnce = shouldAlertMoreThanOnce, alertMoreThanOnce = shouldAlertMoreThanOnce,
smallIcon = R.drawable.ic_notification_small_icon, smallIcon = R.drawable.ic_notification_small_icon,