diff --git a/program/js/app.js b/program/js/app.js index 51469170a..4f2f96e4a 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3806,15 +3806,27 @@ function rcube_webmail() // wrapper for the mailvelope.createDisplayContainer API call this.mailvelope_display_container = function(selector, data, keyring, msgid) { - mailvelope.createDisplayContainer(selector, data, keyring, { showExternalContent: this.env.safemode }).then(function() { - $(selector).addClass('mailvelope').children().not('iframe').hide(); + var error_handler = function(error) { + // remove mailvelope frame with the error message + $(selector + ' > iframe').remove(); ref.hide_message(msgid); - setTimeout(function() { $(window).resize(); }, 10); - }, function(err) { - console.error(err); + ref.display_message(error.message, 'error'); + }; + + mailvelope.createDisplayContainer(selector, data, keyring, { showExternalContent: this.env.safemode }).then(function(status) { + if (status.error && status.error.message) { + return error_handler(status.error); + } + ref.hide_message(msgid); - ref.display_message('Message decryption failed: ' + err.message, 'error') - }); + $(selector).addClass('mailvelope').children().not('iframe').hide(); + + // on success we can remove encrypted part from the attachments list + if (ref.env.pgp_mime_part) + $('#attach' + ref.env.pgp_mime_part).remove(); + + setTimeout(function() { $(window).resize(); }, 10); + }, error_handler); }; // subroutine to query keyservers for public keys diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 3d52e1c74..62fe8ffef 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -189,7 +189,8 @@ function rcmail_message_attachments($attrib) $filesize = $RCMAIL->message_part_size($attach_prop); if ($PRINT_MODE) { - $ol .= html::tag('li', null, rcube::Q(sprintf("%s (%s)", $filename, $filesize))); + $ol .= html::tag('li', array('id' => 'attach' . $attach_prop->mime_id), + rcube::Q(sprintf("%s (%s)", $filename, $filesize))); } else { if ($attrib['maxlength'] && mb_strlen($filename) > $attrib['maxlength']) { diff --git a/skins/classic/functions.js b/skins/classic/functions.js index df181c730..c4b0f7a69 100644 --- a/skins/classic/functions.js +++ b/skins/classic/functions.js @@ -1085,6 +1085,9 @@ function rcube_init_mail_ui() }); $(window).resize(function() { + if (!$('#attachment-list > li[id^="attach"]').length) + $('#attachment-list').hide(); + var mvlpe = $('#messagebody.mailvelope'); if (mvlpe.length) { var content = $('#messageframe'), diff --git a/skins/larry/mail.css b/skins/larry/mail.css index 83e0b710a..dc5dbb9d5 100644 --- a/skins/larry/mail.css +++ b/skins/larry/mail.css @@ -868,6 +868,10 @@ div.hide-headers { margin: 8px; } +#messagebody.mailvelope { + margin: 0; +} + #message-objects div, #messagebody span.part-notice { margin: 8px; diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 984892315..d4d450a57 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -525,7 +525,7 @@ function rcube_mail_ui() if (mvlpe.length) { var h = $('#messagecontent').length ? $('#messagecontent').height() - 16 : - $(window).height() - mvlpe.offset().top - 10; + $(window).height() - mvlpe.offset().top - 2; mvlpe.height(h); } }