Skip to content

Commit

Permalink
Merge pull request #1849 from Infomaniak/fix-empty-group-notifications
Browse files Browse the repository at this point in the history
Fix condition to know if the group notification for a specific mailbox is empty
  • Loading branch information
KevinBoulongne committed May 14, 2024
2 parents c5712fd + ee54f5a commit 2418350
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,17 @@ class FetchMessagesManager @Inject constructor(
}
}

// We don't need to display a group notification saying "0 new messages" so
// if we don't have any active notifications, we dismiss the group notification.
if (notificationManagerCompat.activeNotifications.isEmpty()) {
notificationManagerCompat.cancel(mailbox.notificationGroupId)
/**
* We don't want to display an empty group notification saying "0 new messages".
*
* If we only have 1 active notification for a specific Mailbox, it means that there is either :
* - 1 normal notification,
* - or 1 empty group notification.
* In case of the later, we need to cancel it.
*/
with(notificationManagerCompat) {
val mailboxGroupNotifications = activeNotifications.filter { it.notification.group == mailbox.notificationGroupKey }
if (mailboxGroupNotifications.size == 1) cancel(mailbox.notificationGroupId)
}

if (threadsWithNewMessages.isEmpty()) {
Expand Down

0 comments on commit 2418350

Please sign in to comment.