From 7a784f1fcde168da83773466c17c2f512d8230a8 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 22 Feb 2022 02:18:27 +0100 Subject: [PATCH] Remove 'new message' notification when user marks the message as read We already handled the case where the message was marked as read on the server. This handles the case where the user marks the message as read locally. --- .../com/fsck/k9/controller/MessagingController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java index ff1cb2fa4..329cfc87a 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -1167,6 +1167,10 @@ public class MessagingController { l.folderStatusChanged(account, folderId); } + if (flag == Flag.SEEN && newState) { + cancelNotificationsForMessages(account, folderId, uids); + } + if (accountSupportsFlags) { LocalFolder localFolder = localStore.getFolder(folderId); try { @@ -1183,6 +1187,13 @@ public class MessagingController { } } + private void cancelNotificationsForMessages(Account account, long folderId, List uids) { + for (String uid : uids) { + MessageReference messageReference = new MessageReference(account.getUuid(), folderId, uid); + notificationController.removeNewMailNotification(account, messageReference); + } + } + /** * Set or remove a flag for a set of messages in a specific folder. *