Fix potential edge case unseen messages

pull/162/head
M66B 5 years ago
parent f84100d9e1
commit f44b5a7815

@ -154,17 +154,18 @@ public class ServiceSynchronize extends ServiceBase {
@Override @Override
public void onChanged(TupleMessageStats stats) { public void onChanged(TupleMessageStats stats) {
if (stats != null) { if (stats == null)
boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false); stats = new TupleMessageStats();
if (!unseen_ignored || stats.ignored == null)
stats.ignored = 0;
if (!stats.equals(lastStats)) { boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
Log.i("Stats " + stats); if (!unseen_ignored || stats.ignored == null)
lastStats = stats; stats.ignored = 0;
setUnseen(stats.unseen - stats.ignored); if (!stats.equals(lastStats)) {
} Log.i("Stats " + stats);
lastStats = stats;
setUnseen(stats.unseen - stats.ignored);
} }
} }
}); });

@ -25,8 +25,8 @@ import androidx.annotation.Nullable;
import java.util.Objects; import java.util.Objects;
public class TupleMessageStats { public class TupleMessageStats {
public Integer unseen; public Integer unseen = 0;
public Integer ignored; public Integer ignored = 0;
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {

Loading…
Cancel
Save