From ab8eec41db125888950254e57f27248bf9f76339 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 1 Feb 2010 00:10:50 -0700 Subject: [PATCH] Need to update cacheid in ShowPreview return if mailbox hasn't changed but message was previously marked as unseen --- imp/js/DimpBase.js | 4 ++-- imp/lib/Ajax/Application.php | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index ca34ad2a6..30bd673d2 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -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) diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index c849cb110..3f3988cae 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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: *
      * 'uid' - (string) Index of the messages to preview (IMAP sequence
      *         string) - must be single index.
      * 
* - * @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: + *
+     * 'preview' - (object) Return from IMP_View_ShowMessage::showMessage().
+     * 'ViewPort' - (object) See _viewPortData(). (Only returns updatecacheid
+     *                       entry - don't do mailbox poll here).
+     * 
*/ 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(); -- 2.11.0