From 1038c9ff71b8e64183385d76adc72591dfc0c6fc Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 Aug 2018 14:24:11 +0000 Subject: [PATCH] Unified inboxes of synchronizing accounts only --- app/src/main/java/eu/faircode/email/DaoMessage.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 49515a39..0868c94c 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -35,15 +35,17 @@ public interface DaoMessage { // all bare columns in the result set take values from the input row which also contains the minimum or maximum." // https://www.sqlite.org/lang_select.html - @Query("SELECT message.*, account.name AS accountName, folder.name as folderName, folder.type as folderType" + + @Query("SELECT message.*, maccount.name AS accountName, folder.name as folderName, folder.type as folderType" + ", COUNT(message.id) as count" + ", SUM(CASE WHEN message.ui_seen THEN 0 ELSE 1 END) as unseen" + ", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" + ", MAX(CASE WHEN folder.type = '" + EntityFolder.INBOX + "' THEN message.id ELSE 0 END) as dummy" + " FROM message" + - " LEFT JOIN account ON account.id = message.account" + + " LEFT JOIN account maccount ON maccount.id = message.account" + " JOIN folder ON folder.id = message.folder" + - " WHERE (NOT message.ui_hide OR :debug)" + + " JOIN account ON account.id = folder.account" + + " WHERE account.`synchronize`" + + " AND (NOT message.ui_hide OR :debug)" + " GROUP BY CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" + " HAVING SUM(CASE WHEN folder.type = '" + EntityFolder.INBOX + "' THEN 1 ELSE 0 END) > 0" + " ORDER BY message.received DESC")