From: Michael M Slusarz Date: Thu, 24 Dec 2009 08:17:26 +0000 (-0700) Subject: Request #7297: Only update search mailbox on explicit user action X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9ab3adc6193cc2b841067a94a199a7c62efe4b13;p=horde.git Request #7297: Only update search mailbox on explicit user action --- diff --git a/imp/ajax.php b/imp/ajax.php index 78a05a2b9..f8acd9f2c 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -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); diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index a63ebfb96..05fb122ae 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -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). diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index 3f64a9270..536999d6d 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -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. */ diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index 8926bee9a..994023898 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -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 ''; } @@ -48,6 +49,7 @@ function _simpleButton($id, $text, $image)