From 2ba5a88cea8de82514602c30bad6ee78ffb21464 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 Jan 2020 15:32:35 +0100 Subject: [PATCH] Widget: fixed showing unified account messages (QA) --- app/src/main/java/eu/faircode/email/DaoMessage.java | 3 ++- .../email/WidgetUnifiedRemoteViewsFactory.java | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index f6759fcf1e..8e217f869d 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -384,6 +384,7 @@ public interface DaoMessage { " JOIN account_view AS account ON account.id = message.account" + " JOIN folder_view AS folder ON folder.id = message.folder" + " WHERE account.`synchronize`" + + " AND (:account IS NULL OR account.id = :account)" + " AND ((:folder IS NULL AND folder.unified) OR folder.id = :folder)" + " AND NOT message.ui_hide" + " AND message.ui_snoozed IS NULL" + @@ -393,7 +394,7 @@ public interface DaoMessage { ", CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " ORDER BY message.received DESC") @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) - List getWidgetUnified(Long folder, boolean threading, boolean unseen, boolean flagged); + List getWidgetUnified(Long account, Long folder, boolean threading, boolean unseen, boolean flagged); @Query("SELECT uid FROM message" + " WHERE folder = :folder" + diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index a80d876a9e..276f86c205 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -84,13 +84,10 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot try { db.beginTransaction(); - if (folder < 0 && account > 0) { - EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); - if (inbox != null) - folder = inbox.id; - } - - messages = db.message().getWidgetUnified(folder < 0 ? null : folder, threading, unseen, flagged); + messages = db.message().getWidgetUnified( + account < 0 ? null : account, + folder < 0 ? null : folder, + threading, unseen, flagged); db.setTransactionSuccessful(); } finally {