Skip to content

Commit

Permalink
Make list existence determination optional when getting message data
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Jan 14, 2015
1 parent 98f6a93 commit 0a72dd2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions imp/js/smartmobile.js
Expand Up @@ -717,7 +717,8 @@ var ImpMobile = {
$.extend(ImpMobile.addViewportParams($.extend(params, {
view: purl.params.mbox
})), {
buid: purl.params.buid
buid: purl.params.buid,
is_list: 1
}),
ImpMobile.messageLoaded
);
Expand Down Expand Up @@ -810,7 +811,7 @@ var ImpMobile = {
subject: data.subject,
to: data.to
};
ImpMobile.listmsg = (data.list_info && data.list_info.exists);
ImpMobile.listmsg = data.is_list;
ImpMobile.rowid = r.buid;

$.fn[cache.readonly ? 'hide' : 'show'].call($('#imp-message-delete'));
Expand Down
10 changes: 9 additions & 1 deletion imp/lib/Ajax/Application/Handler/Common.php
Expand Up @@ -654,6 +654,7 @@ public function redirectMessage()
* See the list of variables needed for changed() and
* checkUidvalidity(). Mailbox/indices form parameters needed. Additional
* variables used:
* - is_list: (boolean) If true, check for list existence.
* - peek: (integer) If set, don't set seen flag.
* - preview: (integer) If set, return preview data. Otherwise, return
* full data.
Expand All @@ -676,7 +677,14 @@ public function showMessage()
throw new IMP_Exception(_("Could not open mailbox."));
}

$this->_base->queue->message($this->_base->indices, $this->vars->preview, $this->vars->peek);
$this->_base->queue->message(
$this->_base->indices,
array(
'is_list' => (bool)$this->vars->is_list,
'peek' => (bool)$this->vars->peek,
'preview' => (bool)$this->vars->preview
)
);

/* Explicitly load the message here; non-existent messages are
* ignored when the Ajax queue is processed. Place the check AFTER
Expand Down
5 changes: 4 additions & 1 deletion imp/lib/Ajax/Application/Handler/Dynamic.php
Expand Up @@ -935,7 +935,10 @@ public function stripAttachment()
$result = new stdClass;
$result->puids = $this->_base->previewUids();

$this->_base->queue->message($this->_base->indices, true);
$this->_base->queue->message(
$this->_base->indices,
array('preview' => true)
);
$this->_base->addTask('viewport', $this->_base->viewPortData(true));

return $result;
Expand Down
22 changes: 16 additions & 6 deletions imp/lib/Ajax/Queue.php
Expand Up @@ -441,19 +441,22 @@ public function flagConfig($view)
* Add message data to output.
*
* @param IMP_Indices $indices Index of the message.
* @param boolean $preview Preview data?
* @param boolean $peek Don't set seen flag?
* @param array $opts Additional options:
* <pre>
* - is_list: (boolean) Do list check?
* - peek: (boolean) Don't set seen flag?
* - preview: (boolean) Preview data?
* </pre>
*/
public function message(IMP_Indices $indices, $preview = false,
$peek = false)
public function message(IMP_Indices $indices, array $opts = array())
{
global $page_output;

try {
$show_msg = new IMP_Ajax_Application_ShowMessage($indices, $peek);
$show_msg = new IMP_Ajax_Application_ShowMessage($indices, !empty($opts['peek']));
$msg = (object)$show_msg->showMessage();

if ($preview) {
if (!empty($opts['preview'])) {
/* Need to grab cached inline scripts. */
Horde::startBuffer();
$page_output->outputInlineScript(true);
Expand All @@ -465,6 +468,13 @@ public function message(IMP_Indices $indices, $preview = false,
$msg->headers = $show_msg->getUserHeaders();
}

if (!empty($opts['is_list'])) {
$list_info = $show_msg->contents->getListInformation();
if (!empty($list_info['exists'])) {
$msg->is_list = true;
}
}

$msg->save_as = strval($msg->save_as);

if ($indices instanceof IMP_Indices_Mailbox) {
Expand Down

2 comments on commit 0a72dd2

@joaomachado
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing changes here:

--- a/imp/lib/Ajax/Application.php
+++ b/imp/lib/Ajax/Application.php
@@ -106,7 +106,13 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application

         /* Check for global msgload task. */
         if (isset($this->_vars->msgload)) {
-            $this->queue->message($this->indices->mailbox->fromBuids(array($this->_vars->msgload)), true, true);
+            $this->queue->message(
+                $this->indices->mailbox->fromBuids(array($this->_vars->msgload)),
+                array(
+                    'preview' => true,
+                    'peek' => true
+                )
+            );
         }

         /* Check for global poll task. */

@slusarz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

Please sign in to comment.