Need to update cacheid in ShowPreview return if mailbox hasn't changed but message...
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 1 Feb 2010 07:10:50 +0000 (00:10 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 1 Feb 2010 07:20:23 +0000 (00:20 -0700)
imp/js/DimpBase.js
imp/lib/Ajax/Application.php

index ca34ad2..30bd673 100644 (file)
@@ -1134,7 +1134,7 @@ var DimpBase = {
             if (this.ppfifo.indexOf(pp_uid) != -1) {
                   // There is a chance that the message may have been marked
                   // as unseen since first being viewed. If so, we need to
-                  // explicitly flag as seen here.
+                  // explicitly flag as seen here. TODO?
                 if (!this.hasFlag('\\seen', data)) {
                     this.flag('\\seen', true);
                 }
@@ -1144,7 +1144,7 @@ var DimpBase = {
 
         this.loadingImg('msg', true);
 
-        DimpCore.doAction('ShowPreview', params || {}, { uids: this.viewport.createSelection('dataob', this.pp), callback: this._loadPreviewCallback.bind(this) });
+        DimpCore.doAction('ShowPreview', this.viewport.addRequestParams(params || {}), { uids: this.viewport.createSelection('dataob', this.pp), callback: this._loadPreviewCallback.bind(this) });
     },
 
     _loadPreviewCallback: function(resp)
index c849cb1..3f3988c 100644 (file)
@@ -802,16 +802,20 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
      * AJAX action: Generate data necessary to display preview message.
      *
      * @param Horde_Variables $vars  See the list of variables needed for
-     *                               _checkUidvalidity(). Additional variables
-     *                               used:
+     *                               _changed() and _checkUidvalidity().
+     *                               Additional variables used:
      * <pre>
      * 'uid' - (string) Index of the messages to preview (IMAP sequence
      *         string) - must be single index.
      * </pre>
      *
-     * @return mixed  False on failure, or an object with the 'preview'
-     *                property containing the return value from
-     *                IMP_View_ShowMessage::showMessage().
+     * @return mixed  False on failure, or an object with the following
+     *                entries:
+     * <pre>
+     * 'preview' - (object) Return from IMP_View_ShowMessage::showMessage().
+     * 'ViewPort' - (object) See _viewPortData(). (Only returns updatecacheid
+     *                       entry - don't do mailbox poll here).
+     * </pre>
      */
     public function ShowPreview($vars)
     {
@@ -820,6 +824,11 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
             return false;
         }
 
+        $change = $this->_changed($vars, $indices);
+        if (is_null($change)) {
+            return false;
+        }
+
         $ptr = each($indices);
         $args = array(
             'mailbox' => $ptr['key'],
@@ -838,6 +847,14 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
             $result->preview = (object)$show_msg->showMessage($args);
             if (isset($result->preview->error)) {
                 $result = $this->_checkUidvalidity($vars, $result);
+            } elseif (!$change) {
+                /* Only update cacheid info if it changed. */
+                $cacheid = IMP_Mailbox::singleton($vars->view)->getCacheID($vars->view);
+                if ($cacheid != $vars->cacheid) {
+                    $result->ViewPort = new stdClass;
+                    $result->ViewPort->updatecacheid = $cacheid;
+                    $result->ViewPort->view = $vars->view;
+                }
             }
         } catch (Horde_Imap_Client_Exception $e) {
             $result->preview->error = $e->getMessage();