Don't queue pending command for setting flags if not supported
If the backend doesn't support setting flags (POP3) or the folder is a local-only folder (Outbox), don't add a pending command that is guaranteed to fail.
@@ -1092,6 +1092,8 @@ public class MessagingController {
return;
}
+ boolean accountSupportsFlags = supportsFlags(account);
+
// Loop over all folders
for (Entry<Long, List<String>> entry : folderMap.entrySet()) {
long folderId = entry.getKey();
@@ -1102,12 +1104,20 @@ public class MessagingController {
l.folderStatusChanged(account, folderId);
}
- // TODO: Skip the remote part for all local-only folders
-
+ if (accountSupportsFlags) {
+ LocalFolder localFolder = localStore.getFolder(folderId);
+ try {
+ localFolder.open();
+ if (!localFolder.isLocalOnly()) {
// Send flag change to server
queueSetFlag(account, folderId, newState, flag, uids);
processPendingCommands(account);
}
+ } catch (MessagingException e) {
+ Timber.e(e, "Couldn't open folder. Account: %s, folder ID: %d", account, folderId);
+ }
+ }
+ }
}
/**
@@ -1131,16 +1141,12 @@ public class MessagingController {
l.folderStatusChanged(account, folderId);
}
-
- /*
- * Handle the remote side
- */
-
- // TODO: Skip the remote part for all local-only folders
-
+ // Handle the remote side
+ if (supportsFlags(account) && !localFolder.isLocalOnly()) {
List<String> uids = getUidsFromMessages(messages);
queueSetFlag(account, folderId, newState, flag, uids);
processPendingCommands(account);
+ }
} catch (MessagingException me) {
throw new RuntimeException(me);
}
