Added filtering unflagged messages

This commit is contained in:
M66B
2019-05-13 12:57:20 +02:00
parent 42ff71fe4c
commit d0054214b4
4 changed files with 65 additions and 7 deletions

View File

@@ -69,6 +69,7 @@ public interface DaoMessage {
" GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" +
" HAVING :found OR SUM(unified) > 0" +
" AND (NOT :filter_seen OR " + unseen_unified + " > 0)" +
" AND (NOT :filter_unflagged OR COUNT(message.id) - " + unflagged_unified + " > 0)" +
" ORDER BY" +
" CASE" +
" WHEN 'unread' = :sort THEN " + unseen_unified + " = 0" +
@@ -81,7 +82,11 @@ public interface DaoMessage {
" END, message.received DESC")
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
DataSource.Factory<Integer, TupleMessageEx> pagedUnifiedInbox(
boolean threading, String sort, boolean filter_seen, boolean filter_snoozed, boolean found, boolean debug);
boolean threading,
String sort,
boolean filter_seen, boolean filter_unflagged, boolean filter_snoozed,
boolean found,
boolean debug);
String unseen_folder = "SUM(CASE WHEN message.ui_seen" +
" OR (folder.id <> :folder AND folder.type = '" + EntityFolder.ARCHIVE + "')" +
@@ -116,6 +121,7 @@ public interface DaoMessage {
" GROUP BY CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" +
" HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" +
" AND (NOT :filter_seen OR " + unseen_folder + " > 0 OR folder.type = '" + EntityFolder.OUTBOX + "')" +
" AND (NOT :filter_unflagged OR COUNT(message.id) - " + unflagged_folder + " > 0 OR folder.type = '" + EntityFolder.OUTBOX + "')" +
" ORDER BY" +
" CASE" +
" WHEN 'unread' = :sort THEN " + unseen_folder + " = 0" +
@@ -128,7 +134,11 @@ public interface DaoMessage {
" END, message.received DESC")
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
DataSource.Factory<Integer, TupleMessageEx> pagedFolder(
long folder, boolean threading, String sort, boolean filter_seen, boolean filter_snoozed, boolean found, boolean debug);
long folder, boolean threading,
String sort,
boolean filter_seen, boolean filter_unflagged, boolean filter_snoozed,
boolean found,
boolean debug);
@Query("SELECT message.*" +
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +