Rename OneShotNotification.key to OneShotNotification.tag for clarity.

This commit is contained in:
Benoit Marty 2025-10-26 09:05:12 +01:00 committed by Benoit Marty
parent 7d7ea5d67c
commit 7ee00a65d8
4 changed files with 13 additions and 13 deletions

View file

@ -114,7 +114,7 @@ class DefaultNotificationDataFactory(
): List<OneShotNotification> { ): List<OneShotNotification> {
return map { event -> return map { event ->
OneShotNotification( OneShotNotification(
key = event.roomId.value, tag = event.roomId.value,
notification = notificationCreator.createRoomInvitationNotification(notificationAccountParams, event), notification = notificationCreator.createRoomInvitationNotification(notificationAccountParams, event),
summaryLine = event.description, summaryLine = event.description,
isNoisy = event.noisy, isNoisy = event.noisy,
@ -130,7 +130,7 @@ class DefaultNotificationDataFactory(
): List<OneShotNotification> { ): List<OneShotNotification> {
return map { event -> return map { event ->
OneShotNotification( OneShotNotification(
key = event.eventId.value, tag = event.eventId.value,
notification = notificationCreator.createSimpleEventNotification(notificationAccountParams, event), notification = notificationCreator.createSimpleEventNotification(notificationAccountParams, event),
summaryLine = event.description, summaryLine = event.description,
isNoisy = event.noisy, isNoisy = event.noisy,
@ -146,7 +146,7 @@ class DefaultNotificationDataFactory(
): List<OneShotNotification> { ): List<OneShotNotification> {
return map { event -> return map { event ->
OneShotNotification( OneShotNotification(
key = event.eventId.value, tag = event.eventId.value,
notification = notificationCreator.createFallbackNotification(notificationAccountParams, event), notification = notificationCreator.createFallbackNotification(notificationAccountParams, event),
summaryLine = event.description.orEmpty(), summaryLine = event.description.orEmpty(),
isNoisy = false, isNoisy = false,
@ -239,7 +239,7 @@ data class RoomNotification(
data class OneShotNotification( data class OneShotNotification(
val notification: Notification, val notification: Notification,
val key: String, val tag: String,
val summaryLine: CharSequence, val summaryLine: CharSequence,
val isNoisy: Boolean, val isNoisy: Boolean,
val timestamp: Long, val timestamp: Long,

View file

@ -94,9 +94,9 @@ class NotificationRenderer(
invitationNotifications.forEach { notificationData -> invitationNotifications.forEach { notificationData ->
if (useCompleteNotificationFormat) { if (useCompleteNotificationFormat) {
Timber.tag(loggerTag.value).d("Updating invitation notification ${notificationData.key}") Timber.tag(loggerTag.value).d("Updating invitation notification ${notificationData.tag}")
notificationDisplayer.showNotificationMessage( notificationDisplayer.showNotificationMessage(
tag = notificationData.key, tag = notificationData.tag,
id = NotificationIdProvider.getRoomInvitationNotificationId(currentUser.userId), id = NotificationIdProvider.getRoomInvitationNotificationId(currentUser.userId),
notification = notificationData.notification notification = notificationData.notification
) )
@ -105,9 +105,9 @@ class NotificationRenderer(
simpleNotifications.forEach { notificationData -> simpleNotifications.forEach { notificationData ->
if (useCompleteNotificationFormat) { if (useCompleteNotificationFormat) {
Timber.tag(loggerTag.value).d("Updating simple notification ${notificationData.key}") Timber.tag(loggerTag.value).d("Updating simple notification ${notificationData.tag}")
notificationDisplayer.showNotificationMessage( notificationDisplayer.showNotificationMessage(
tag = notificationData.key, tag = notificationData.tag,
id = NotificationIdProvider.getRoomEventNotificationId(currentUser.userId), id = NotificationIdProvider.getRoomEventNotificationId(currentUser.userId),
notification = notificationData.notification notification = notificationData.notification
) )

View file

@ -60,7 +60,7 @@ class NotificationDataFactoryTest {
listOf( listOf(
OneShotNotification( OneShotNotification(
notification = expectedNotification, notification = expectedNotification,
key = A_ROOM_ID.value, tag = A_ROOM_ID.value,
summaryLine = AN_INVITATION_EVENT.description, summaryLine = AN_INVITATION_EVENT.description,
isNoisy = AN_INVITATION_EVENT.noisy, isNoisy = AN_INVITATION_EVENT.noisy,
timestamp = AN_INVITATION_EVENT.timestamp timestamp = AN_INVITATION_EVENT.timestamp
@ -79,7 +79,7 @@ class NotificationDataFactoryTest {
assertThat(result).containsExactly( assertThat(result).containsExactly(
OneShotNotification( OneShotNotification(
notification = expectedNotification, notification = expectedNotification,
key = AN_EVENT_ID.value, tag = AN_EVENT_ID.value,
summaryLine = A_SIMPLE_EVENT.description, summaryLine = A_SIMPLE_EVENT.description,
isNoisy = A_SIMPLE_EVENT.noisy, isNoisy = A_SIMPLE_EVENT.noisy,
timestamp = AN_INVITATION_EVENT.timestamp timestamp = AN_INVITATION_EVENT.timestamp

View file

@ -42,7 +42,7 @@ private const val USE_COMPLETE_NOTIFICATION_FORMAT = true
private val A_SUMMARY_NOTIFICATION = SummaryNotification.Update(A_NOTIFICATION) private val A_SUMMARY_NOTIFICATION = SummaryNotification.Update(A_NOTIFICATION)
private val ONE_SHOT_NOTIFICATION = private val ONE_SHOT_NOTIFICATION =
OneShotNotification(notification = A_NOTIFICATION, key = "ignored", summaryLine = "ignored", isNoisy = false, timestamp = -1) OneShotNotification(notification = A_NOTIFICATION, tag = "ignored", summaryLine = "ignored", isNoisy = false, timestamp = -1)
@RunWith(RobolectricTestRunner::class) @RunWith(RobolectricTestRunner::class)
class NotificationRendererTest { class NotificationRendererTest {
@ -86,7 +86,7 @@ class NotificationRendererTest {
@Test @Test
fun `given a simple notification is added when rendering then show the simple notification and update summary`() = runTest { fun `given a simple notification is added when rendering then show the simple notification and update summary`() = runTest {
notificationCreator.createSimpleNotificationResult = lambdaRecorder { _, _ -> ONE_SHOT_NOTIFICATION.copy(key = AN_EVENT_ID.value).notification } notificationCreator.createSimpleNotificationResult = lambdaRecorder { _, _ -> ONE_SHOT_NOTIFICATION.copy(tag = AN_EVENT_ID.value).notification }
renderEventsAsNotifications(listOf(aSimpleNotifiableEvent(eventId = AN_EVENT_ID))) renderEventsAsNotifications(listOf(aSimpleNotifiableEvent(eventId = AN_EVENT_ID)))
@ -98,7 +98,7 @@ class NotificationRendererTest {
@Test @Test
fun `given an invitation notification is added when rendering then show the invitation notification and update summary`() = runTest { fun `given an invitation notification is added when rendering then show the invitation notification and update summary`() = runTest {
notificationCreator.createRoomInvitationNotificationResult = lambdaRecorder { _, _ -> ONE_SHOT_NOTIFICATION.copy(key = AN_EVENT_ID.value).notification } notificationCreator.createRoomInvitationNotificationResult = lambdaRecorder { _, _ -> ONE_SHOT_NOTIFICATION.copy(tag = AN_EVENT_ID.value).notification }
renderEventsAsNotifications(listOf(anInviteNotifiableEvent())) renderEventsAsNotifications(listOf(anInviteNotifiableEvent()))