mirror of https://github.com/M66B/FairEmail.git
Take filters into account when counting visible
This commit is contained in:
parent
48051e67bd
commit
14cd6f2c45
|
@ -5172,11 +5172,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
protected List<Long> onExecute(Context context, Bundle args) throws Throwable {
|
protected List<Long> onExecute(Context context, Bundle args) throws Throwable {
|
||||||
long[] ids = args.getLongArray("ids");
|
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<>();
|
List<Long> removed = new ArrayList<>();
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
for (long id : ids)
|
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);
|
removed.add(id);
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
|
|
|
@ -360,8 +360,13 @@ public interface DaoMessage {
|
||||||
int countMessageByMsgId(long folder, String msgid);
|
int countMessageByMsgId(long folder, String msgid);
|
||||||
|
|
||||||
@Query("SELECT COUNT(*) FROM message" +
|
@Query("SELECT COUNT(*) FROM message" +
|
||||||
" WHERE id = :id AND NOT ui_hide")
|
" JOIN folder_view AS folder ON folder.id = message.folder" +
|
||||||
int countVisible(long id);
|
" 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.*" +
|
@Query("SELECT message.*" +
|
||||||
", account.pop AS accountProtocol, account.name AS accountName, identity.color AS accountColor" +
|
", account.pop AS accountProtocol, account.name AS accountName, identity.color AS accountColor" +
|
||||||
|
|
Loading…
Reference in New Issue