mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Notify listeners if unread count changed due to a copy/move operation
This commit is contained in:
parent
d4bc664c41
commit
98461e5a21
@ -3297,12 +3297,17 @@ public class MessagingController implements Runnable {
|
||||
Folder localSrcFolder = localStore.getFolder(srcFolder);
|
||||
Folder localDestFolder = localStore.getFolder(destFolder);
|
||||
|
||||
boolean unreadCountAffected = false;
|
||||
List<String> uids = new LinkedList<String>();
|
||||
for (Message message : inMessages) {
|
||||
String uid = message.getUid();
|
||||
if (!uid.startsWith(K9.LOCAL_UID_PREFIX)) {
|
||||
uids.add(uid);
|
||||
}
|
||||
|
||||
if (!unreadCountAffected && !message.isSet(Flag.SEEN)) {
|
||||
unreadCountAffected = true;
|
||||
}
|
||||
}
|
||||
|
||||
Message[] messages = localSrcFolder.getMessages(uids.toArray(EMPTY_STRING_ARRAY), null);
|
||||
@ -3323,6 +3328,15 @@ public class MessagingController implements Runnable {
|
||||
fp.add(FetchProfile.Item.BODY);
|
||||
localSrcFolder.fetch(messages, fp, null);
|
||||
localSrcFolder.copyMessages(messages, localDestFolder);
|
||||
|
||||
if (unreadCountAffected) {
|
||||
// If this copy operation changes the unread count in the destination
|
||||
// folder, notify the listeners.
|
||||
int unreadMessageCount = localDestFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, destFolder, unreadMessageCount);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localSrcFolder.moveMessages(messages, localDestFolder);
|
||||
for (Map.Entry<String, Message> entry : origUidMap.entrySet()) {
|
||||
@ -3333,6 +3347,17 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
unsuppressMessage(account, srcFolder, origUid);
|
||||
}
|
||||
|
||||
if (unreadCountAffected) {
|
||||
// If this move operation changes the unread count, notify the listeners
|
||||
// that the unread count changed in both the source and destination folder.
|
||||
int unreadMessageCountSrc = localSrcFolder.getUnreadMessageCount();
|
||||
int unreadMessageCountDest = localDestFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, srcFolder, unreadMessageCountSrc);
|
||||
l.folderStatusChanged(account, destFolder, unreadMessageCountDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
queueMoveOrCopy(account, srcFolder, destFolder, isCopy, origUidMap.keySet().toArray(EMPTY_STRING_ARRAY));
|
||||
|
Loading…
Reference in New Issue
Block a user