From 6ea780d5244f737a6aa1ceedf64e26f0f73686e8 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 26 Aug 2018 05:28:36 +0000 Subject: [PATCH] Fixed setting seen --- app/src/main/java/eu/faircode/email/ActivityView.java | 10 ++++------ app/src/main/java/eu/faircode/email/DaoMessage.java | 3 ++- .../main/java/eu/faircode/email/FragmentCompose.java | 2 -- .../main/java/eu/faircode/email/FragmentMessage.java | 10 ++++------ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index cb45f955de..9c3631df57 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -665,12 +665,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack db.beginTransaction(); EntityMessage message = db.message().getMessage(id); - for (EntityMessage tmessage : db.message().getMessageByThread(message.account, message.thread)) - if (message.uid != null) { // Skip drafts and outbox - db.message().setMessageUiSeen(tmessage.id, true); - - EntityOperation.queue(db, tmessage, EntityOperation.SEEN, true); - } + for (EntityMessage tmessage : db.message().getMessageByThread(message.account, message.thread)) { + db.message().setMessageUiSeen(tmessage.id, true); + EntityOperation.queue(db, tmessage, EntityOperation.SEEN, true); + } db.setTransactionSuccessful(); } finally { diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 5ac8f0887c..b7ba86c1b9 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -103,7 +103,8 @@ public interface DaoMessage { @Query("SELECT message.* FROM message" + " JOIN folder ON folder.id = message.folder" + " WHERE message.account = :account" + - " AND message.thread = :thread") + " AND message.thread = :thread" + + " AND folder.type <> '" + EntityFolder.OUTBOX + "'") List getMessageByThread(long account, String thread); @Query("SELECT message.*, account.name AS accountName, folder.name as folderName, folder.type as folderType" + diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 41a6492f66..00819eb441 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1027,8 +1027,6 @@ public class FragmentCompose extends FragmentEx { db.message().updateMessage(draft); draft.write(context, pbody); - EntityOperation.queue(db, draft, EntityOperation.SEEN, true); - EntityFolder trash = db.folder().getFolderByType(draft.account, EntityFolder.TRASH); EntityOperation.queue(db, draft, EntityOperation.MOVE, trash.id); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 35fa995422..00018a4fc1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -713,12 +713,10 @@ public class FragmentMessage extends FragmentEx { db.beginTransaction(); EntityMessage message = db.message().getMessage(id); - for (EntityMessage tmessage : db.message().getMessageByThread(message.account, message.thread)) - if (message.uid != null) { // Skip drafts and outbox - db.message().setMessageUiSeen(tmessage.id, !message.ui_seen); - - EntityOperation.queue(db, tmessage, EntityOperation.SEEN, !tmessage.ui_seen); - } + for (EntityMessage tmessage : db.message().getMessageByThread(message.account, message.thread)) { + db.message().setMessageUiSeen(tmessage.id, !message.ui_seen); + EntityOperation.queue(db, tmessage, EntityOperation.SEEN, !tmessage.ui_seen); + } db.setTransactionSuccessful(); } finally {