Update flag in base view also if currently in search view
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 15 Apr 2009 02:55:36 +0000 (20:55 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 15 Apr 2009 02:55:36 +0000 (20:55 -0600)
imp/js/src/DimpBase.js

index 5cf5ba9..795ace0 100644 (file)
@@ -2162,15 +2162,29 @@ var DimpBase = {
         add = this.convertFlag(flag, add);
 
         vs.get('dataob').each(function(ob) {
-            ob.flag = ob.flag.without(flag);
-            if (add) {
-                ob.flag.push(flag);
+            this._updateFlag(ob, flag, add);
+
+            /* If this is a search mailbox, also need to update flag in base
+             * view, if it is in the buffer. */
+            if (this.isSearch()) {
+                var tmp = this.viewport.getSelection(ob.view).search({ imapuid: { equal: [ ob.imapuid ] }, view: { equal: [ ob.view ] } });
+                if (tmp.size()) {
+                    this._updateFlag(tmp.get('dataob').first(), flag, add);
+                }
             }
-
-            this.viewport.updateRow(ob);
         }, this);
     },
 
+    _updateFlag: function(ob, flag, add)
+    {
+        ob.flag = ob.flag.without(flag);
+        if (add) {
+            ob.flag.push(flag);
+        }
+
+        this.viewport.updateRow(ob);
+    },
+
     /* Miscellaneous folder actions. */
     purgeDeleted: function()
     {