From f44b5a78153a2f2c6d448f8b749d3d9c5faa01a4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 22 Sep 2019 13:51:52 +0200 Subject: [PATCH] Fix potential edge case unseen messages --- .../eu/faircode/email/ServiceSynchronize.java | 19 ++++++++++--------- .../eu/faircode/email/TupleMessageStats.java | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 3c9c2abba9..8f3561ae5f 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -154,17 +154,18 @@ public class ServiceSynchronize extends ServiceBase { @Override public void onChanged(TupleMessageStats stats) { - if (stats != null) { - boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false); - if (!unseen_ignored || stats.ignored == null) - stats.ignored = 0; + if (stats == null) + stats = new TupleMessageStats(); - if (!stats.equals(lastStats)) { - Log.i("Stats " + stats); - lastStats = stats; + boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false); + if (!unseen_ignored || stats.ignored == null) + stats.ignored = 0; - setUnseen(stats.unseen - stats.ignored); - } + if (!stats.equals(lastStats)) { + Log.i("Stats " + stats); + lastStats = stats; + + setUnseen(stats.unseen - stats.ignored); } } }); diff --git a/app/src/main/java/eu/faircode/email/TupleMessageStats.java b/app/src/main/java/eu/faircode/email/TupleMessageStats.java index 0cd0be2467..f15e1e2448 100644 --- a/app/src/main/java/eu/faircode/email/TupleMessageStats.java +++ b/app/src/main/java/eu/faircode/email/TupleMessageStats.java @@ -25,8 +25,8 @@ import androidx.annotation.Nullable; import java.util.Objects; public class TupleMessageStats { - public Integer unseen; - public Integer ignored; + public Integer unseen = 0; + public Integer ignored = 0; @Override public boolean equals(@Nullable Object obj) {