mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Collect keywords
This commit is contained in:
parent
e9d9278129
commit
fa90cf96b6
1 changed files with 13 additions and 17 deletions
|
@ -874,8 +874,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
db.folder().setFolderState(folder.id, "connected");
|
||||
db.folder().setFolderError(folder.id, null);
|
||||
|
||||
updateKeywords(db, folder, ifolder.getPermanentFlags().getUserFlags());
|
||||
|
||||
Log.i(Helper.TAG, account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags());
|
||||
|
||||
// Synchronize folder
|
||||
|
@ -1316,17 +1314,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateKeywords(DB db, EntityFolder folder, String[] merge) {
|
||||
List<String> keywords = new ArrayList<>(Arrays.asList(folder.keywords));
|
||||
for (String keyword : merge)
|
||||
if (!keywords.contains(keyword))
|
||||
keywords.add(keyword);
|
||||
|
||||
Collections.sort(keywords);
|
||||
|
||||
db.folder().setFolderKeywords(folder.id, DB.Converters.fromStringArray(keywords.toArray(new String[0])));
|
||||
}
|
||||
|
||||
private void processOperations(EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, ServiceState state) throws MessagingException, JSONException, IOException {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
|
@ -1524,10 +1511,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
} else
|
||||
keywords.remove(keyword);
|
||||
db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(keywords.toArray(new String[0])));
|
||||
|
||||
if (!set)
|
||||
keywords.add(keyword);
|
||||
updateKeywords(db, folder, keywords.toArray(new String[0]));
|
||||
}
|
||||
|
||||
private void doAdd(EntityFolder folder, Session isession, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException, IOException {
|
||||
|
@ -2193,6 +2176,19 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
db.message().updateMessage(message);
|
||||
}
|
||||
|
||||
List<String> fkeywords = new ArrayList<>(Arrays.asList(folder.keywords));
|
||||
|
||||
for (String keyword : keywords)
|
||||
if (!fkeywords.contains(keyword)) {
|
||||
Log.i(Helper.TAG, folder.name + " adding keyword=" + keyword);
|
||||
fkeywords.add(keyword);
|
||||
}
|
||||
|
||||
if (folder.keywords.length != fkeywords.size()) {
|
||||
Collections.sort(fkeywords);
|
||||
db.folder().setFolderKeywords(folder.id, DB.Converters.fromStringArray(fkeywords.toArray(new String[0])));
|
||||
}
|
||||
|
||||
return message.id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue