Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove notifications on read from another client [WPB-1881] #2802

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

addNotifications(newNotifications, userId, userName)
updateNotifications(newNotifications, userId)
removeSeenNotifications(newNotifications, userId)

Check warning on line 62 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L62

Added line #L62 was not covered by tests

appLogger.i("$TAG: handled notifications: newNotifications size ${newNotifications.size}; ")
}
Expand Down Expand Up @@ -90,7 +91,20 @@

removeSummaryIfNeeded(userId)

appLogger.i("$TAG: added notifications: newNotifications size ${notificationsToUpdate.size}; ")
appLogger.i("$TAG: updated notifications: newNotifications size ${notificationsToUpdate.size}; ")

Check warning on line 94 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L94

Added line #L94 was not covered by tests
}

private fun removeSeenNotifications(newNotifications: List<LocalNotification>, userId: QualifiedID) {
val notificationsToUpdate: List<LocalNotification.ConversationSeen> = newNotifications
.filterIsInstance(LocalNotification.ConversationSeen::class.java)

Check warning on line 99 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L98-L99

Added lines #L98 - L99 were not covered by tests

notificationsToUpdate.groupBy { it.conversationId }.forEach { (conversationId, _) ->
hideNotification(conversationId, userId)

Check warning on line 102 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L101-L102

Added lines #L101 - L102 were not covered by tests
}

removeSummaryIfNeeded(userId)

Check warning on line 105 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L105

Added line #L105 was not covered by tests

appLogger.i("$TAG: removed ${notificationsToUpdate.size} notifications, it was seen;")

Check warning on line 107 in app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/MessageNotificationManager.kt#L107

Added line #L107 was not covered by tests
}

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 @@
override val author: NotificationMessageAuthor,
override val time: Long,
val authorId: String
) :
NotificationMessage(messageId, author, time)
) : NotificationMessage(messageId, author, time)

Check warning on line 101 in app/src/main/kotlin/com/wire/android/notification/Models.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/Models.kt#L101

Added line #L101 was not covered by tests

data class ConversationDeleted(
override val messageId: String,
override val author: NotificationMessageAuthor,
override val time: Long
) :
NotificationMessage(messageId, author, time)
) : NotificationMessage(messageId, author, time)

Check warning on line 107 in app/src/main/kotlin/com/wire/android/notification/Models.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/Models.kt#L107

Added line #L107 was not covered by tests
}

data class NotificationMessageAuthor(val name: String, val image: ByteArray?) {
Expand Down Expand Up @@ -157,6 +155,7 @@
)
}

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

val notificationMessageTime = time.toEpochMilliseconds()
Expand Down
Loading