Request #7297: Only update search mailbox on explicit user action
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 24 Dec 2009 08:17:26 +0000 (01:17 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 24 Dec 2009 09:07:28 +0000 (02:07 -0700)
imp/ajax.php
imp/docs/CHANGES
imp/js/DimpBase.js
imp/templates/index/index-dimp.inc
imp/themes/screen-dimp.css
imp/themes/silver/screen-dimp.css

index 78a05a2..f8acd9f 100644 (file)
@@ -43,10 +43,11 @@ function _generateDeleteResult($mbox, $indices, $change, $nothread = false)
     return $result;
 }
 
-function _changed($mbox, $compare, $rw = null)
+function _changed($mbox, $compare, $action, $rw = null)
 {
-    if ($GLOBALS['imp_search']->isVFolder($mbox)) {
-        return true;
+    /* Only update search mailboxes on forced refreshes. */
+    if ($GLOBALS['imp_search']->isSearchMbox($mbox)) {
+        return ($action == 'ViewPort') || Horde_Util::getPost('forceUpdate');
     }
 
     /* We know we are going to be dealing with this mailbox, so select it on
@@ -373,7 +374,7 @@ case 'Poll':
 
     $changed = false;
     if (!empty($mbox)) {
-        $changed =_changed($mbox, $cacheid);
+        $changed =_changed($mbox, $cacheid, $action);
         if ($changed) {
             $result->ViewPort = _getListMessages($mbox, true);
         }
@@ -408,7 +409,7 @@ case 'ViewPort':
         IMP::setSort($sortby, $sortdir, $mbox);
     }
 
-    $changed = _changed($mbox, $cacheid, false);
+    $changed = _changed($mbox, $cacheid, $action, false);
 
     if (is_null($changed)) {
         $list_msg = new IMP_Views_ListMessages();
@@ -435,7 +436,7 @@ case 'CopyMessage':
     }
 
     $change = ($action == 'MoveMessage')
-        ? _changed($mbox, $cacheid, true)
+        ? _changed($mbox, $cacheid, $action, true)
         : false;
 
     if (!is_null($change)) {
@@ -504,7 +505,7 @@ case 'DeleteMessage':
     }
 
     $imp_message = IMP_Message::singleton();
-    $change = _changed($mbox, $cacheid, true);
+    $change = _changed($mbox, $cacheid, $action, true);
 
     if ($imp_message->delete($indices)) {
         $result = _generateDeleteResult($mbox, $indices, $change, !$prefs->getValue('hide_deleted') && !$prefs->getValue('use_trash'));
@@ -532,7 +533,7 @@ case 'AddContact':
     break;
 
 case 'ReportSpam':
-    $change = _changed($mbox, $cacheid, false);
+    $change = _changed($mbox, $cacheid, $action, false);
 
     if (IMP_Spam::reportSpam($indices, Horde_Util::getPost('spam') ? 'spam' : 'notspam')) {
         $result = _generateDeleteResult($mbox, $indices, $change);
@@ -551,7 +552,7 @@ case 'Blacklist':
 
     $imp_filter = new IMP_Filter();
     if (Horde_Util::getPost('blacklist')) {
-        $change = _changed($mbox, $cacheid, false);
+        $change = _changed($mbox, $cacheid, $action, false);
         if (!is_null($change)) {
             try {
                 if ($imp_filter->blacklistMessage($indices, false)) {
@@ -753,7 +754,7 @@ case 'chunkContent':
     break;
 
 case 'PurgeDeleted':
-    $change = _changed($mbox, $cacheid, $indices);
+    $change = _changed($mbox, $cacheid, $action, $indices);
     if (!is_null($change)) {
         if (!$change) {
             $sort = IMP::getSort($mbox);
index a63ebfb..05fb122 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Only update search mailbox on explicit user action (Request #7297).
 [mms] Add auto-save draft to IMP (Request #7656).
 [mms] Add keyboard shortcut to move to next unseen message (Request #8223).
 [mms] Add hook to dynamically change mailbox label (Request #6734).
index 3f64a92..536999d 100644 (file)
@@ -338,9 +338,13 @@ var DimpBase = {
 
                 this.folder = f;
 
-                if (this.isSearch(f) &&
-                    (!this.search || this.search.flag)) {
-                    this._quicksearchDeactivate(!this.search);
+                if (this.isSearch(f)) {
+                    if (!this.search || this.search.flag) {
+                        this._quicksearchDeactivate(!this.search);
+                    }
+                    $('refreshlink').show();
+                } else {
+                    $('refreshlink').hide();
                 }
             }
         }
@@ -1403,9 +1407,10 @@ var DimpBase = {
     },
 
     /* Folder list updates. */
-    poll: function()
+    poll: function(force)
     {
-        var args = {};
+        var args = {},
+            check = 'checkmaillink';
 
         // Reset poll folder counter.
         this.setPoll();
@@ -1418,7 +1423,13 @@ var DimpBase = {
             this.viewport.getMetaData('label')) {
             args = this.viewport.addRequestParams({});
         }
-        $('checkmaillink').down('A').update('[' + DIMP.text.check + ']');
+
+        if (force) {
+            args.set('forceUpdate', 1);
+            check = 'refreshlink';
+        }
+
+        $(check).down('A').update('[' + DIMP.text.check + ']');
         DimpCore.doAction('Poll', args);
     },
 
@@ -1435,6 +1446,9 @@ var DimpBase = {
         }
 
         $('checkmaillink').down('A').update(DIMP.text.getmail);
+        if ($('refreshlink').visible()) {
+            $('refreshlink').down('A').update(DIMP.text.refresh);
+        }
     },
 
     _displayQuota: function(r)
@@ -1931,7 +1945,8 @@ var DimpBase = {
                 return;
 
             case 'checkmaillink':
-                this.poll();
+            case 'refreshlink':
+                this.poll(id == 'refreshlink');
                 e.stop();
                 return;
 
@@ -2906,6 +2921,7 @@ var DimpBase = {
 
         /* Store these text strings for updating purposes. */
         DIMP.text.getmail = $('checkmaillink').down('A').innerHTML;
+        DIMP.text.refresh = $('refreshlink').down('A').innerHTML;
         DIMP.text.showalog = $('alertsloglink').down('A').innerHTML;
 
         /* Initialize the starting page. */
index 8926bee..9940238 100644 (file)
@@ -21,12 +21,13 @@ $show_quota = (isset($_SESSION['imp']['quota']) && is_array($_SESSION['imp']['qu
 $imp_flags = IMP_Imap_Flags::singleton();
 $flag_list = $imp_flags->getList(array('imap' => true));
 
-function _simpleButton($id, $text, $image)
+function _simpleButton($id, $text, $image, $nodisplay = false)
 {
     $ak = Horde::getAccessKey($text, true);
     return '<li class="servicelink"' .
         (strlen($id) ? ' id="' . $id . '"' : '') .
-        (strlen($ak) ? ' accesskey="' . $ak . '"' : '') . '>' .
+        (strlen($ak) ? ' accesskey="' . $ak . '"' : '') .
+        ($nodisplay ? ' style="display:none"' : '') . '>' .
         '<span class="iconSpan ' . $image . '"></span>' .
         '<a>' . Horde::highlightAccessKey($text, $ak) . '</a></li>';
 }
@@ -48,6 +49,7 @@ function _simpleButton($id, $text, $image)
    <ul id="dimpbarActions">
     <?php echo _simpleButton('composelink', _("_New Message"), 'dimpactionCompose') ?>
     <?php echo _simpleButton('checkmaillink', _("_Get Mail"), 'dimpactionCheckmail') ?>
+    <?php echo _simpleButton('refreshlink', _("_Refresh Search"), 'dimpactionRefresh', true) ?>
     <?php echo _simpleButton('alertsloglink', _("Alerts _Log"), 'infoIcon') ?>
 <?php if (!empty($_SESSION['imp']['filteravail'])): ?>
     <?php echo _simpleButton('applyfilterlink', _("Apply Filters"), 'filtersIcon') ?>
index 99823a8..cf14a1f 100644 (file)
@@ -903,6 +903,9 @@ span.dimpactionCompose {
 span.dimpactionCheckmail {
     background-image: url("graphics/checkmail.png");
 }
+span.dimpactionRefresh {
+    background-image: url("graphics/reload.png");
+}
 span.dimpactionDelete {
     background-image: url("graphics/delete.png");
 }
index 9bb73ae..7f674fa 100644 (file)
@@ -63,6 +63,9 @@ span.dimpactionCompose {
 span.dimpactionCheckmail {
     background-image: url("graphics/checkmail.png");
 }
+span.dimpactionRefresh {
+    background-image: url("graphics/reload.png");
+}
 span.dimpactionDelete {
     background-image: url("graphics/delete.png");
 }