Skip to content

Commit

Permalink
Merge branch 'develop' into feat/message-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Mar 21, 2024
2 parents 893c918 + 50ccd98 commit 6b0d372
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}; ")
}
Expand Down Expand Up @@ -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<LocalNotification>, userId: QualifiedID) {
val notificationsToUpdate: List<LocalNotification.ConversationSeen> = 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) {
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/kotlin/com/wire/android/notification/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down Expand Up @@ -157,6 +155,7 @@ fun LocalNotification.Conversation.intoNotificationConversation(): NotificationC
)
}

@Suppress("LongMethod")
fun LocalNotificationMessage.intoNotificationMessage(): NotificationMessage {

val notificationMessageTime = time.toEpochMilliseconds()
Expand Down

0 comments on commit 6b0d372

Please sign in to comment.