@ -481,28 +481,30 @@ public interface DaoMessage {
LiveData<List<TupleMessageEx>>liveUnseenNotify();
LiveData<List<TupleMessageEx>>liveUnseenNotify();
@Transaction
@Transaction
@Query("SELECT account.id AS account, COUNT(message.id) AS unseen, SUM(NOT ui_ignored) AS notifying"+
@Query("SELECT account.id AS account,"+
" COUNT(message.id) AS unseen,"+
" SUM(CASE WHEN account.created IS NULL OR message.received > account.created OR message.sent > account.created THEN NOT ui_ignored ELSE 0 END) AS notifying"+
" FROM message"+
" FROM message"+
" JOIN account_view AS account ON account.id = message.account"+
" JOIN account_view AS account ON account.id = message.account"+
" JOIN folder_view AS folder ON folder.id = message.folder"+
" JOIN folder_view AS folder ON folder.id = message.folder"+
" WHERE (:account IS NULL OR account.id = :account)"+
" WHERE (:account IS NULL OR account.id = :account)"+
" AND account.`synchronize`"+
" AND account.`synchronize`"+
" AND folder.notify"+
" AND folder.notify"+
" AND (account.created IS NULL OR message.received > account.created OR message.sent > account.created)"+
" AND message.notifying <> "+EntityMessage.NOTIFYING_IGNORE+
" AND message.notifying <> "+EntityMessage.NOTIFYING_IGNORE+
@Query("SELECT :account AS account, COUNT(message.id) AS unseen, SUM(NOT ui_ignored) AS notifying"+
@Query("SELECT :account AS account,"+
" COUNT(message.id) AS unseen,"+
" SUM(CASE WHEN account.created IS NULL OR message.received > account.created OR message.sent > account.created THEN NOT ui_ignored ELSE 0 END) AS notifying"+
" FROM message"+
" FROM message"+
" JOIN account_view AS account ON account.id = message.account"+
" JOIN account_view AS account ON account.id = message.account"+
" JOIN folder_view AS folder ON folder.id = message.folder"+
" JOIN folder_view AS folder ON folder.id = message.folder"+
" WHERE (:account IS NULL OR account.id = :account)"+
" WHERE (:account IS NULL OR account.id = :account)"+
" AND account.`synchronize`"+
" AND account.`synchronize`"+
" AND folder.notify"+
" AND folder.notify"+
" AND (account.created IS NULL OR message.received > account.created OR message.sent > account.created)"+
" AND message.notifying <> "+EntityMessage.NOTIFYING_IGNORE+
" AND message.notifying <> "+EntityMessage.NOTIFYING_IGNORE+