Take filters into account when counting visible

This commit is contained in:
M66B 2020-06-03 16:24:48 +02:00
parent 48051e67bd
commit 14cd6f2c45
2 changed files with 13 additions and 3 deletions

View File

@ -5172,11 +5172,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected List<Long> onExecute(Context context, Bundle args) throws Throwable {
long[] ids = args.getLongArray("ids");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean filter_seen = prefs.getBoolean("filter_seen", false);
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
boolean filter_snoozed = prefs.getBoolean("filter_snoozed", true);
List<Long> removed = new ArrayList<>();
DB db = DB.getInstance(context);
for (long id : ids)
if (db.message().countVisible(id) == 0)
if (db.message().countVisible(id, filter_seen, filter_unflagged, filter_snoozed) == 0)
removed.add(id);
return removed;

View File

@ -360,8 +360,13 @@ public interface DaoMessage {
int countMessageByMsgId(long folder, String msgid);
@Query("SELECT COUNT(*) FROM message" +
" WHERE id = :id AND NOT ui_hide")
int countVisible(long id);
" JOIN folder_view AS folder ON folder.id = message.folder" +
" WHERE message.id = :id" +
" AND NOT message.ui_hide" +
" AND (NOT :filter_seen OR NOT message.ui_seen)" +
" AND (NOT :filter_unflagged OR message.ui_flagged)" +
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_drafts + ")")
int countVisible(long id, boolean filter_seen, boolean filter_unflagged, boolean filter_snoozed);
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, identity.color AS accountColor" +