diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 2096d5aaf8..455cf1f7b6 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1986,9 +1986,8 @@ class Core { // Difference for (String group : groupMessages.keySet()) { // Difference - List add = new ArrayList<>(); - List remove = new ArrayList<>(groupNotifying.get(group)); - List notify = new ArrayList<>(); + final List add = new ArrayList<>(); + final List remove = new ArrayList<>(groupNotifying.get(group)); for (TupleMessageEx message : groupMessages.get(group)) { long id = (message.content ? message.id : -message.id); if (remove.contains(id)) { @@ -1997,7 +1996,6 @@ class Core { } else { remove.remove(-id); add.add(id); - notify.add(message); Log.i("Notify adding=" + id); } } @@ -2008,7 +2006,7 @@ class Core { } // Build notifications - List notifications = getNotificationUnseen(context, group, notify); + List notifications = getNotificationUnseen(context, group, groupMessages.get(group)); Log.i("Notify group=" + group + " count=" + notifications.size() + " added=" + add.size() + " removed=" + remove.size()); @@ -2027,7 +2025,7 @@ class Core { for (Notification notification : notifications) { long id = notification.extras.getLong("id", 0); - if (id != 0 || add.size() + remove.size() > 0) { + if ((id == 0 && add.size() + remove.size() > 0) || add.contains(id)) { String tag = "unseen." + group + "." + Math.abs(id); Log.i("Notifying tag=" + tag + (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId()));