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
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);
}
}
});

@ -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) {

Loading…
Cancel
Save