From 4b3b4781f06a0401a70c7239f58d9254e659d656 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 5 Jul 2022 07:28:04 +0200 Subject: [PATCH] Preset new folder keywords --- .../java/eu/faircode/email/EntityOperation.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index e6b8f71d6f..549144fbdb 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -169,6 +169,19 @@ public class EntityOperation { message.keywords = keywords.toArray(new String[0]); db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(message.keywords)); + if (set) { + EntityFolder folder = db.folder().getFolder(message.folder); + if (folder != null) { + List fkeywords = new ArrayList<>(); + if (folder.keywords != null) + fkeywords.addAll(Arrays.asList(folder.keywords)); + if (!fkeywords.contains(keyword)) + fkeywords.add(keyword); + Collections.sort(fkeywords); + db.folder().setFolderKeywords(folder.id, DB.Converters.fromStringArray(message.keywords)); + } + } + } else if (LABEL.equals(name)) { String label = jargs.getString(0); boolean set = jargs.getBoolean(1);