diff --git a/app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt b/app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt index a84de5e60ba..99f2de18724 100644 --- a/app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt +++ b/app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt @@ -59,6 +59,7 @@ class MessageNotificationManager addNotifications(newNotifications, userId, userName) updateNotifications(newNotifications, userId) + removeSeenNotifications(newNotifications, userId) appLogger.i("$TAG: handled notifications: newNotifications size ${newNotifications.size}; ") } @@ -90,7 +91,20 @@ class MessageNotificationManager removeSummaryIfNeeded(userId) - appLogger.i("$TAG: added notifications: newNotifications size ${notificationsToUpdate.size}; ") + appLogger.i("$TAG: updated notifications: newNotifications size ${notificationsToUpdate.size}; ") + } + + private fun removeSeenNotifications(newNotifications: List, userId: QualifiedID) { + val notificationsToUpdate: List = newNotifications + .filterIsInstance(LocalNotification.ConversationSeen::class.java) + + notificationsToUpdate.groupBy { it.conversationId }.forEach { (conversationId, _) -> + hideNotification(conversationId, userId) + } + + removeSummaryIfNeeded(userId) + + appLogger.i("$TAG: removed ${notificationsToUpdate.size} notifications, it was seen;") } fun hideNotification(conversationsId: ConversationId, userId: QualifiedID) { diff --git a/app/src/main/kotlin/com/wire/android/notification/Models.kt b/app/src/main/kotlin/com/wire/android/notification/Models.kt index 2f28ed0a032..e5ef79d0c69 100644 --- a/app/src/main/kotlin/com/wire/android/notification/Models.kt +++ b/app/src/main/kotlin/com/wire/android/notification/Models.kt @@ -98,15 +98,13 @@ sealed class NotificationMessage(open val messageId: String, open val author: No override val author: NotificationMessageAuthor, override val time: Long, val authorId: String - ) : - NotificationMessage(messageId, author, time) + ) : NotificationMessage(messageId, author, time) data class ConversationDeleted( override val messageId: String, override val author: NotificationMessageAuthor, override val time: Long - ) : - NotificationMessage(messageId, author, time) + ) : NotificationMessage(messageId, author, time) } data class NotificationMessageAuthor(val name: String, val image: ByteArray?) { @@ -157,6 +155,7 @@ fun LocalNotification.Conversation.intoNotificationConversation(): NotificationC ) } +@Suppress("LongMethod") fun LocalNotificationMessage.intoNotificationMessage(): NotificationMessage { val notificationMessageTime = time.toEpochMilliseconds()