From 539ee934ea1e2598ddb5dd59dc4fd0ef53915b8f Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Aug 2018 17:39:24 +0000 Subject: [PATCH] Fixed grouping of messages without thread --- app/src/main/java/eu/faircode/email/DaoMessage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 228a5733..b867c825 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -37,7 +37,9 @@ public interface DaoMessage { " JOIN message ON folder = folder.id" + " WHERE folder.type = '" + EntityFolder.TYPE_INBOX + "'" + " AND NOT ui_hide" + - " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder GROUP BY m.thread)") + " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder" + + " GROUP BY CASE WHEN m.thread IS NULL THEN m.id ELSE m.thread END)") + // in theory the message id and thread could be the same LiveData> liveUnifiedInbox(); @Query("SELECT message.*, folder.name as folderName, folder.type as folderType" + @@ -47,7 +49,8 @@ public interface DaoMessage { " JOIN message ON folder = folder.id" + " WHERE folder.id = :folder" + " AND NOT ui_hide" + - " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder GROUP BY m.thread)") + " AND received IN (SELECT MAX(m.received) FROM message m WHERE m.folder = message.folder" + + " GROUP BY CASE WHEN m.thread IS NULL THEN m.id ELSE m.thread END)") LiveData> liveMessages(long folder); @Query("SELECT message.*, folder.name as folderName, folder.type as folderType" +