mirror of https://github.com/M66B/FairEmail.git
Simplification/fix
This commit is contained in:
parent
ebd6269379
commit
43440e3b07
|
@ -248,7 +248,7 @@ public interface DaoMessage {
|
|||
" WHERE message.id = :id")
|
||||
LiveData<TupleMessageEx> liveMessage(long id);
|
||||
|
||||
@Query("SELECT COUNT(message.id) AS unseen, SUM(message.ui_ignored) AS ignored" +
|
||||
@Query("SELECT COUNT(message.id) AS unseen, SUM(ABS(notifying)) AS notifying" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" JOIN folder ON folder.id = message.folder" +
|
||||
|
|
|
@ -150,7 +150,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
db.message().liveUnseen().observe(this, new Observer<TupleMessageStats>() {
|
||||
private TupleMessageStats lastStats = null;
|
||||
private Integer lastUnseen = null;
|
||||
|
||||
@Override
|
||||
public void onChanged(TupleMessageStats stats) {
|
||||
|
@ -158,14 +158,14 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
stats = new TupleMessageStats();
|
||||
|
||||
boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
|
||||
if (!unseen_ignored || stats.ignored == null)
|
||||
stats.ignored = 0;
|
||||
Integer unseen = (unseen_ignored ? stats.notifying : stats.unseen);
|
||||
if (unseen == null)
|
||||
unseen = 0;
|
||||
|
||||
if (!stats.equals(lastStats)) {
|
||||
if (lastUnseen == null || !lastUnseen.equals(unseen)) {
|
||||
Log.i("Stats " + stats);
|
||||
lastStats = stats;
|
||||
|
||||
setUnseen(stats.unseen - stats.ignored);
|
||||
lastUnseen = unseen;
|
||||
setUnseen(unseen);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,15 +25,15 @@ import androidx.annotation.Nullable;
|
|||
import java.util.Objects;
|
||||
|
||||
public class TupleMessageStats {
|
||||
public Integer unseen = 0;
|
||||
public Integer ignored = 0;
|
||||
public Integer unseen;
|
||||
public Integer notifying;
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof TupleMessageStats) {
|
||||
TupleMessageStats other = (TupleMessageStats) obj;
|
||||
return (Objects.equals(this.unseen, other.unseen) &&
|
||||
Objects.equals(this.ignored, other.ignored));
|
||||
Objects.equals(this.notifying, other.notifying));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ public class TupleMessageStats {
|
|||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "unseen=" + unseen + " ignored=" + ignored;
|
||||
return "unseen=" + unseen + " notify=" + notifying;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue