From a859c1562bf183d5391127e4027fefc593552125 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 10 May 2021 17:51:54 +0200 Subject: [PATCH] Keep sent messages in user folders --- app/src/main/java/eu/faircode/email/Core.java | 2 +- app/src/main/java/eu/faircode/email/DaoMessage.java | 3 ++- app/src/main/java/eu/faircode/email/ServiceSend.java | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index e0a81c2bc0..fcec322f89 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2973,7 +2973,7 @@ class Core { // Delete not synchronized messages without uid if (!EntityFolder.isOutgoing(folder.type)) { - int orphans = db.message().deleteOrphans(folder.id); + int orphans = db.message().deleteOrphans(folder.id, new Date().getTime()); Log.i(folder.name + " deleted orphans=" + orphans); } diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index cd41bdf3db..f77a495d96 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -821,6 +821,7 @@ public interface DaoMessage { @Query("DELETE FROM message" + " WHERE folder = :folder" + " AND uid IS NULL" + + " AND (ui_busy IS NULL OR ui_busy < :now)" + " AND NOT EXISTS" + " (SELECT * FROM operation" + " WHERE operation.message = message.id" + @@ -831,7 +832,7 @@ public interface DaoMessage { " WHERE o.account = message.account" + " AND o.name = '" + EntityOperation.MOVE + "'" + " AND m.msgid = message.msgid)") - int deleteOrphans(long folder); + int deleteOrphans(long folder, long now); @Query("SELECT * FROM message" + " WHERE folder = :folder" + diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index f84debdbcc..83875ab07e 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -594,6 +594,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar message.seen = true; message.ui_seen = true; message.ui_hide = true; + message.ui_busy = Long.MAX_VALUE; // Needed to keep messages in user folders message.error = null; message.id = db.message().insertMessage(message);