diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 90c6005863..455cf1f7b6 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1985,24 +1985,29 @@ class Core { // Difference for (String group : groupMessages.keySet()) { - List notifications = getNotificationUnseen(context, group, groupMessages.get(group)); - + // Difference 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)) { + remove.remove(id); + Log.i("Notify existing=" + id); + } else { + remove.remove(-id); + add.add(id); + Log.i("Notify adding=" + id); + } + } - for (Notification notification : notifications) { - Long id = notification.extras.getLong("id", 0); - if (id != 0) - if (remove.contains(id)) { - remove.remove(id); - Log.i("Notify existing=" + id); - } else { - remove.remove(-id); - add.add(id); - Log.i("Notify adding=" + id); - } + if (remove.size() + add.size() == 0) { + Log.i("Notify unchanged"); + continue; } + // Build notifications + List notifications = getNotificationUnseen(context, group, groupMessages.get(group)); + Log.i("Notify group=" + group + " count=" + notifications.size() + " added=" + add.size() + " removed=" + remove.size());