diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index 03d9558d5e..ff7be24215 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -87,9 +87,10 @@ public class AdapterFolder extends RecyclerView.Adapter() { @Override protected Void onExecute(Context context, Bundle args) { long id = args.getLong("id"); - boolean outbox = args.getBoolean("outbox"); - Log.i("Delete local messages outbox=" + outbox); - if (outbox) - DB.getInstance(context).message().deleteSeenMessages(id); + boolean browsed = args.getBoolean("browsed"); + Log.i("Delete local messages browsed=" + browsed); + if (browsed) + DB.getInstance(context).message().deleteBrowsedMessages(id); else DB.getInstance(context).message().deleteLocalMessages(id); return null; diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index d496134e0c..e1869a440c 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -852,7 +852,7 @@ class Core { Log.i(folder.name + " sync=" + new Date(sync_time) + " keep=" + new Date(keep_time)); // Delete old local messages - int old = db.message().deleteMessagesBefore(folder.id, keep_time, false); + int old = db.message().deleteMessagesBefore(folder.id, keep_time); Log.i(folder.name + " local old=" + old); // Get list of local uids diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 309f99336f..6970ec9041 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -354,6 +354,12 @@ public interface DaoMessage { " AND NOT uid IS NULL") int deleteLocalMessages(long folder); + @Query("DELETE FROM message" + + " WHERE folder = :folder" + + " AND ui_browsed" + + " AND NOT uid IS NULL") + int deleteBrowsedMessages(long folder); + @Query("DELETE FROM message" + " WHERE folder = :folder" + " AND uid IS NULL" + @@ -364,16 +370,10 @@ public interface DaoMessage { " AND operation.name = '" + EntityOperation.ADD + "')") int deleteOrphans(long folder); - @Query("DELETE FROM message" + - " WHERE folder = :folder" + - " AND seen") - int deleteSeenMessages(long folder); - @Query("DELETE FROM message" + " WHERE folder = :folder" + " AND received < :received" + " AND NOT uid IS NULL" + - " AND (NOT ui_browsed OR :browsed)" + " AND NOT ui_flagged") - int deleteMessagesBefore(long folder, long received, boolean browsed); + int deleteMessagesBefore(long folder, long received); } \ No newline at end of file diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index b1fe80fbb6..dfd612fa78 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -248,7 +248,7 @@ public class FragmentFolder extends FragmentBase { sync_days, keep_days); db.folder().setFolderError(id, null); - db.message().deleteMessagesBefore(id, keep_time, true); + db.message().deleteMessagesBefore(id, keep_time); EntityOperation.sync(context, folder.id, true); } diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 0ecf41c37b..9cb20133dd 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -56,7 +56,7 @@ public class WorkerCleanup extends Worker { if (keep_time < 0) keep_time = 0; - int messages = db.message().deleteMessagesBefore(folder.id, keep_time, false); + int messages = db.message().deleteMessagesBefore(folder.id, keep_time); if (messages > 0) Log.i("Cleanup folder=" + folder.account + "/" + folder.name + " before=" + new Date(keep_time) + " deleted=" + messages); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9f2e12ee80..e6303ee771 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -272,6 +272,7 @@ Synchronize now Delete local messages + Delete browsed/searched messages Empty trash Edit properties Edit rules