Generalized auto reselect system folders

pull/206/head
M66B 3 years ago
parent fb9b0a1c42
commit efd5ee93ba

@ -2130,6 +2130,7 @@ class Core {
String[] attrs = ((IMAPFolder) ifolder.second).getAttributes(); String[] attrs = ((IMAPFolder) ifolder.second).getAttributes();
String type = EntityFolder.getType(attrs, fullName, false); String type = EntityFolder.getType(attrs, fullName, false);
if (type != null && if (type != null &&
!EntityFolder.INBOX.equals(type) &&
!EntityFolder.USER.equals(type) && !EntityFolder.USER.equals(type) &&
!EntityFolder.SYSTEM.equals(type)) { !EntityFolder.SYSTEM.equals(type)) {
for (EntityFolder folder : new ArrayList<>(local.values())) for (EntityFolder folder : new ArrayList<>(local.values()))
@ -2146,19 +2147,18 @@ class Core {
db.folder().setFolderName(folder.id, fullName); db.folder().setFolderName(folder.id, fullName);
} }
// Reselect Gmail archive folder // Reselect system folders once
if (EntityFolder.ARCHIVE.equals(type) && account.isGmail()) { String key = "reselected." + account.id + "." + type;
boolean gmail_archive_fixed = prefs.getBoolean("gmail_archive_fixed", false); boolean reselected = prefs.getBoolean(key, false);
if (!gmail_archive_fixed) { if (!reselected) {
prefs.edit().putBoolean("gmail_archive_fixed", true).apply(); prefs.edit().putBoolean(key, true).apply();
EntityFolder archive = db.folder().getFolderByType(account.id, EntityFolder.ARCHIVE); EntityFolder folder = db.folder().getFolderByType(account.id, type);
if (archive == null) { if (folder == null) {
archive = db.folder().getFolderByName(account.id, fullName); folder = db.folder().getFolderByName(account.id, fullName);
if (archive != null) { if (folder != null) {
Log.e("Reselecting Gmail archive=" + fullName); Log.e("Reselecting " + account.name + " " + type + "=" + fullName);
archive.type = EntityFolder.ARCHIVE; folder.type = type;
db.folder().setFolderType(archive.id, archive.type); db.folder().setFolderType(folder.id, folder.type);
}
} }
} }
} }

Loading…
Cancel
Save