From 4d103816b9945416c0c80d075922523ec13e3be7 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 22 Nov 2018 19:44:42 +0100 Subject: [PATCH] Explicitly found --- .../main/java/eu/faircode/email/AdapterFolder.java | 2 +- .../java/eu/faircode/email/AdapterMessage.java | 8 +++++--- .../main/java/eu/faircode/email/DaoMessage.java | 13 +++++++------ .../java/eu/faircode/email/FragmentMessages.java | 14 ++++++++------ .../java/eu/faircode/email/ViewModelBrowse.java | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index f8673b889d..b6380b3df0 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -266,7 +266,7 @@ public class AdapterFolder extends RecyclerView.Adapter() { @@ -605,13 +606,14 @@ public class AdapterMessage extends PagedListAdapter messages = db.message().getMessageByThread(account, thread); + List messages = db.message().getMessageByThread(account, thread, found); for (EntityMessage message : messages) { db.message().setMessageUiSeen(message.id, seen); db.message().setMessageUiIgnored(message.id, true); @@ -679,8 +681,8 @@ public class AdapterMessage extends PagedListAdapter messages = - db.message().getMessageByThread(message.account, message.thread); + List messages = db.message().getMessageByThread( + message.account, message.thread, message.ui_found); for (EntityMessage threaded : messages) { db.message().setMessageUiHide(threaded.id, true); EntityOperation.queue(db, threaded, EntityOperation.MOVE, target); diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 8efffc3706..f5712cea86 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -151,16 +151,16 @@ public interface DaoMessage { @Query("SELECT id" + " FROM message" + " WHERE folder = :folder" + - " AND NOT ui_found" + + " AND ui_found = :found" + " ORDER BY message.received DESC, message.sent DESC") - List getMessageByFolder(long folder); + List getMessageByFolder(long folder, boolean found); @Query("SELECT *" + " FROM message" + " WHERE account = :account" + " AND thread = :thread" + - " AND NOT ui_found") - List getMessageByThread(long account, String thread); + " AND ui_found = :found") + List getMessageByThread(long account, String thread, boolean found); @Query("SELECT message.* FROM message" + " JOIN folder ON folder.id = message.folder" + @@ -172,8 +172,9 @@ public interface DaoMessage { @Query("SELECT * FROM message" + " WHERE folder = :folder" + - " AND ui_seen") - List getMessageSeen(long folder); + " AND ui_seen" + + " AND ui_found = :found") + List getMessageSeen(long folder, boolean found); @Query("SELECT id FROM message" + " WHERE content" + diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 3a929f580c..8d8f08567f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -475,8 +475,8 @@ public class FragmentMessages extends FragmentEx { result.target = target; if (thread) { - List messages = - db.message().getMessageByThread(message.account, message.thread); + List messages = db.message().getMessageByThread( + message.account, message.thread, message.ui_found); for (EntityMessage threaded : messages) { if (!threaded.ui_hide && threaded.folder.equals(message.folder)) result.ids.add(threaded.id); @@ -612,8 +612,8 @@ public class FragmentMessages extends FragmentEx { for (long id : ids) { EntityMessage message = db.message().getMessage(id); - List messages = - db.message().getMessageByThread(message.account, message.thread); + List messages = db.message().getMessageByThread( + message.account, message.thread, message.ui_found); for (EntityMessage threaded : messages) { if (threaded.folder.equals(message.folder)) { db.message().setMessageUiHide(threaded.id, true); @@ -1047,7 +1047,7 @@ public class FragmentMessages extends FragmentEx { try { db.beginTransaction(); - for (EntityMessage message : db.message().getMessageSeen(outbox)) { + for (EntityMessage message : db.message().getMessageSeen(outbox, false)) { EntityIdentity identity = db.identity().getIdentity(message.identity); EntityFolder sent = db.folder().getFolderByType(identity.account, EntityFolder.SENT); if (sent != null) { @@ -1313,6 +1313,7 @@ public class FragmentMessages extends FragmentEx { Bundle args = new Bundle(); args.putLong("account", account); args.putString("thread", thread); + args.putBoolean("found", found); args.putString("folderType", folderType); new SimpleTask() { @@ -1320,6 +1321,7 @@ public class FragmentMessages extends FragmentEx { protected MessageTarget onLoad(Context context, Bundle args) { long account = args.getLong("account"); String thread = args.getString("thread"); + boolean found = args.getBoolean("found"); String folderType = args.getString("folderType"); MessageTarget result = new MessageTarget(); @@ -1330,7 +1332,7 @@ public class FragmentMessages extends FragmentEx { result.target = db.folder().getFolderByType(account, folderType); - List messages = db.message().getMessageByThread(account, thread); + List messages = db.message().getMessageByThread(account, thread, found); for (EntityMessage message : messages) if (message.uid != null && !result.target.id.equals(message.folder)) { result.ids.add(message.id); diff --git a/app/src/main/java/eu/faircode/email/ViewModelBrowse.java b/app/src/main/java/eu/faircode/email/ViewModelBrowse.java index 86544222db..1c57748397 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelBrowse.java +++ b/app/src/main/java/eu/faircode/email/ViewModelBrowse.java @@ -88,7 +88,7 @@ public class ViewModelBrowse extends ViewModel { db.beginTransaction(); if (state.messages == null) - state.messages = db.message().getMessageByFolder(state.fid); + state.messages = db.message().getMessageByFolder(state.fid, false); int matched = 0; for (int i = state.local; i < state.messages.size() && matched < state.pageSize; i++) {