diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 144195fc0b..2d70a6234d 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -215,12 +215,17 @@ public interface DaoMessage { ", SUM(message.ui_seen) AS seen" + " FROM message" + " JOIN account_view AS account ON account.id = message.account" + + " JOIN folder_view AS folder ON folder.id = message.folder" + " WHERE message.account = :account" + " AND message.thread = :thread" + " AND (:id IS NULL OR message.id = :id)" + + " AND (NOT :filter_archive OR folder.type <> '" + EntityFolder.ARCHIVE + + "' OR (SELECT COUNT(m.id) FROM message m" + + " WHERE m.account = message.account" + + " AND (m.hash = message.hash OR m.msgid = message.msgid)) = 1)" + " AND NOT message.ui_hide" + " GROUP BY account.id") - LiveData liveThreadStats(long account, String thread, Long id); + LiveData liveThreadStats(long account, String thread, Long id, boolean filter_archive); @Query("SELECT message.id FROM folder" + " JOIN message ON message.folder = folder.id" + diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 85dbd75286..c66dceab26 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3065,7 +3065,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. break; case THREAD: - db.message().liveThreadStats(account, thread, null).observe(getViewLifecycleOwner(), new Observer() { + db.message().liveThreadStats(account, thread, null, filter_archive).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(TupleThreadStats stats) { if (stats == null)