Optimize new message notifications (1)

pull/160/head
M66B 6 years ago
parent e642c378f2
commit ac71c03f21

@ -1985,14 +1985,11 @@ class Core {
// Difference // Difference
for (String group : groupMessages.keySet()) { for (String group : groupMessages.keySet()) {
List<Notification> notifications = getNotificationUnseen(context, group, groupMessages.get(group)); // Difference
final List<Long> add = new ArrayList<>(); final List<Long> add = new ArrayList<>();
final List<Long> remove = new ArrayList<>(groupNotifying.get(group)); final List<Long> remove = new ArrayList<>(groupNotifying.get(group));
for (TupleMessageEx message : groupMessages.get(group)) {
for (Notification notification : notifications) { long id = (message.content ? message.id : -message.id);
Long id = notification.extras.getLong("id", 0);
if (id != 0)
if (remove.contains(id)) { if (remove.contains(id)) {
remove.remove(id); remove.remove(id);
Log.i("Notify existing=" + id); Log.i("Notify existing=" + id);
@ -2003,6 +2000,14 @@ class Core {
} }
} }
if (remove.size() + add.size() == 0) {
Log.i("Notify unchanged");
continue;
}
// Build notifications
List<Notification> notifications = getNotificationUnseen(context, group, groupMessages.get(group));
Log.i("Notify group=" + group + " count=" + notifications.size() + Log.i("Notify group=" + group + " count=" + notifications.size() +
" added=" + add.size() + " removed=" + remove.size()); " added=" + add.size() + " removed=" + remove.size());

Loading…
Cancel
Save