Add 'updatecacheid' ViewPort return value
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 1 Feb 2010 06:54:46 +0000 (23:54 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 1 Feb 2010 07:20:23 +0000 (00:20 -0700)
imp/js/DimpBase.js
imp/js/ViewPort.js
imp/lib/Ajax/Application.php

index 372a569..e8005de 100644 (file)
@@ -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.
index bf7f339..635d52e 100644 (file)
  * 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);
         }
     },
index 5cbf1e3..d528f33 100644 (file)
@@ -1613,7 +1613,10 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
      *
      * @return object  An object with the following entries:
      * <pre>
-     * '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);