diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 15a212eb55..ea8d62a97e 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -708,8 +708,13 @@ class Core { } DB db = DB.getInstance(context); - List messages = db.message().getMessagesByMsgId(message.account, message.msgid); - if (messages != null) + try { + db.beginTransaction(); + + List messages = db.message().getMessagesByMsgId(message.account, message.msgid); + if (messages == null) + return; + for (EntityMessage m : messages) { EntityFolder f = db.folder().getFolder(m.folder); if (!label.equals(f.name) && m.setLabel(label, set)) { @@ -717,6 +722,11 @@ class Core { db.message().setMessageLabels(m.id, DB.Converters.fromStringArray(m.labels)); } } + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } } private static void onAdd(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws MessagingException, IOException { diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 83a9afbcbc..15b727a9f9 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -154,6 +154,13 @@ public class EntityOperation { db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(keywords.toArray(new String[0]))); + } else if (LABEL.equals(name)) { + String label = jargs.getString(0); + boolean set = jargs.getBoolean(1); + + if (message.setLabel(label, set)) + db.message().setMessageLabels(message.id, DB.Converters.fromStringArray(message.labels)); + } else if (MOVE.equals(name)) { // Parameters: // 0: target folder