W.I.P. of new approach for mail winmail.data attachment handling

- Fix mail list is loading super slow if there are mails with winmail.data attachments
- Performance improvement for reading mails in preview pane with winmail.data
This commit is contained in:
Hadi Nategh 2015-11-27 16:17:59 +00:00
parent 26514e9c4c
commit e1f4574b9a
2 changed files with 51 additions and 1 deletions

View File

@ -3658,6 +3658,38 @@ class mail_ui
}
/**
* ResolveWinmail fetches the encoded attachments
* from winmail.data and will response expected structure back
* to client in order to display them.
*
* Note: this ajax function should only be called via
* nm mail selection as it does not support profile change
* and uses the current available ic_server connection.
*
* @param type $_rowid row id from nm
*
*/
function ajax_resolveWinmail ($_rowid)
{
$response = egw_json_response::get();
$idParts = self::splitRowID($_rowid);
$uid = $idParts['msgUID'];
$mbox = $idParts['folder'];
$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
if (is_array($attachments))
{
$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
$response->data($attachments);
}
else
{
$response->call('egw.message', lang('Can not resolve the winmail.data attachment!'));
}
}
/**
* move folder
*

View File

@ -844,6 +844,24 @@ app.classes.mail = AppJS.extend(
{
var _id = this.mail_fetchCurrentlyFocussed(selected);
dataElem = jQuery.extend(dataElem, egw.dataGetUIDdata(_id));
// Try to resolve winmail.data attachment
if (dataElem.data && dataElem.data.attachmentsBlock[0]
&& dataElem.data.attachmentsBlock[0].winmailFlag)
{
attachmentArea.getDOMNode().classList.add('loading');
this.egw.jsonq('mail.mail_ui.ajax_resolveWinmail',[_id], function(_data){
attachmentArea.getDOMNode().classList.remove('loading');
if (typeof _data == 'object')
{
attachmentArea.set_value({content:_data});
}
else
{
console.log('Can not resolve the winmail.data!');
}
});
}
}
var $preview_iframe = jQuery('#mail-index_mailPreviewContainer');