diff --git a/app/src/main/java/com/infomaniak/mail/utils/FetchMessagesManager.kt b/app/src/main/java/com/infomaniak/mail/utils/FetchMessagesManager.kt index 596af8432c..5811304495 100644 --- a/app/src/main/java/com/infomaniak/mail/utils/FetchMessagesManager.kt +++ b/app/src/main/java/com/infomaniak/mail/utils/FetchMessagesManager.kt @@ -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()) {