[geary] Fix regression where folders were not regularly updated w/ STATUS info



commit c7b56db19a31ff37425fabb1324b70c15fe1d494
Author: Jim Nelson <jim yorba org>
Date:   Wed Jan 29 11:13:36 2014 -0800

    Fix regression where folders were not regularly updated w/ STATUS info
    
    Now that Imap.Folders are being preserved, need to update their
    FolderProperties w/ STATUS results whenever listed.

 src/engine/imap/api/imap-account.vala           |   18 +++++++++---------
 src/engine/imap/api/imap-folder-properties.vala |   13 +++++++++++++
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index 15e8ca1..691d8d9 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -227,13 +227,6 @@ private class Geary.Imap.Account : BaseObject {
         Gee.Map<StatusCommand, MailboxSpecifier> cmd_map = new Gee.HashMap<
             StatusCommand, MailboxSpecifier>();
         foreach (MailboxInformation mailbox_info in child_info) {
-            // if already have an Imap.Folder for this mailbox, use that
-            if (folders.has_key(mailbox_info.path)) {
-                child_folders.add(folders.get(mailbox_info.path));
-                
-                continue;
-            }
-            
             // if new mailbox is unselectable, don't bother doing a STATUS command
             if (mailbox_info.attrs.contains(MailboxAttribute.NO_SELECT)) {
                 Imap.Folder folder = new Imap.Folder.unselectable(session_mgr, mailbox_info);
@@ -286,8 +279,15 @@ private class Geary.Imap.Account : BaseObject {
             
             status_results.remove(found_status);
             
-            Imap.Folder folder = new Imap.Folder(session_mgr, found_status, mailbox_info);
-            folders.set(folder.path, folder);
+            // if already have an Imap.Folder for this mailbox, use that
+            Imap.Folder? folder = folders.get(mailbox_info.path);
+            if (folder != null) {
+                folder.properties.update_status(found_status);
+            } else {
+                folder = new Imap.Folder(session_mgr, found_status, mailbox_info);
+                folders.set(folder.path, folder);
+            }
+            
             child_folders.add(folder);
         }
         
diff --git a/src/engine/imap/api/imap-folder-properties.vala b/src/engine/imap/api/imap-folder-properties.vala
index ab99e56..6a3b9b3 100644
--- a/src/engine/imap/api/imap-folder-properties.vala
+++ b/src/engine/imap/api/imap-folder-properties.vala
@@ -169,6 +169,19 @@ public class Geary.Imap.FolderProperties : Geary.FolderProperties {
         is_openable = Trillian.from_boolean(!attrs.contains(MailboxAttribute.NO_SELECT));
     }
     
+    /**
+     * Update an existing { link FolderProperties} with fresh { link StatusData}.
+     *
+     * This will force the { link email_total} property to match the { link status_messages} value.
+     */
+    public void update_status(StatusData status) {
+        set_status_message_count(status.messages, true);
+        set_status_unseen(status.unseen);
+        recent = status.recent;
+        uid_validity = status.uid_validity;
+        uid_next = status.uid_next;
+    }
+    
     public void set_status_message_count(int messages, bool force) {
         if (messages < 0)
             return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]