From de91a5b448b503fde0e7fc3b66aeb9a6d017d762 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 31 Jan 2010 23:54:46 -0700 Subject: [PATCH] Add 'updatecacheid' ViewPort return value --- imp/js/DimpBase.js | 3 +-- imp/js/ViewPort.js | 13 +++++++------ imp/lib/Ajax/Application.php | 10 ++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index 372a56947..e8005de03 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -2262,8 +2262,7 @@ var DimpBase = { if (search.size()) { if (r.remove) { - // TODO: Don't use cacheid - this.viewport.remove(search, { cacheid: r.cacheid, noupdate: r.ViewPort }); + this.viewport.remove(search, { noupdate: r.ViewPort }); this._expirePPCache(uids); } else { // Need this to catch spam deletions. diff --git a/imp/js/ViewPort.js b/imp/js/ViewPort.js index bf7f339e8..635d52e96 100644 --- a/imp/js/ViewPort.js +++ b/imp/js/ViewPort.js @@ -190,6 +190,9 @@ * totalrows: (integer) Total number of rows in the view. * update [optional]: (integer) If set, update the rowlist instead of * overwriting it. + * updatecacheid [optional]: (string) If set, simply update the cacheid with + * the new value. Indicates that the browser + * contains the up-to-date version of the cache. * view: (string) The view ID of the request. * * @@ -391,7 +394,7 @@ var ViewPort = Class.create({ }, // vs = (Viewport_Selection) A Viewport_Selection object. - // opts = (object) TODO [cacheid, noupdate, view] + // opts = (object) TODO [noupdate, view] remove: function(vs, opts) { if (!vs.size()) { @@ -413,10 +416,6 @@ var ViewPort = Class.create({ this.deselect(vs); - if (opts.cacheid) { - this._getBuffer(opts.view).setMetaData({ cacheid: opts.cacheid }, true); - } - // If we have visible elements to remove, only call refresh after // the last effect has finished. if (vsize) { @@ -807,7 +806,9 @@ var ViewPort = Class.create({ this.opts.container.fire('ViewPort:endFetch', r.view); } - if (!Object.isUndefined(r.cacheid)) { + if (!Object.isUndefined(r.updatecacheid)) { + this._getBuffer(r.view).setMetaData({ cacheid: r.updatecacheid }, true); + } else if (!Object.isUndefined(r.cacheid)) { this._ajaxResponse(r); } }, diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 5cbf1e380..d528f33f7 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1613,7 +1613,10 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base * * @return object An object with the following entries: *
-     * 'deleted' - (object) See _generateDeleteResult().
+     * 'deleted' - (object) TODO:
+     *   folder
+     *   remove
+     *   uids
      * 'ViewPort' - (object) See _viewPortData().
      * 'poll' - (array) Mailbox names as the keys, number of unseen messages
      *          as the values.
@@ -1629,7 +1632,6 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
         $del->uids = $GLOBALS['imp_imap']->ob()->utils->toSequenceString($indices, array('mailbox' => true));
         $del->remove = intval($GLOBALS['prefs']->getValue('hide_deleted') ||
                               $GLOBALS['prefs']->getValue('use_trash'));
-        $del->cacheid = $imp_mailbox->getCacheID($vars->view);
 
         $result = new stdClass;
         $result->deleted = $del;
@@ -1642,6 +1644,10 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
 
         if ($change) {
             $result->ViewPort = $this->_viewPortData($vars, true);
+        } else {
+            $result->ViewPort = new stdClass;
+            $result->ViewPort->updatecacheid = $imp_mailbox->getCacheID($vars->view);
+            $result->ViewPort->view = $vars->view;
         }
 
         $poll = $this->_getPollInformation($vars->view);
-- 
2.11.0