mirror of
https://github.com/moparisthebest/mail
synced 2024-12-22 15:28:49 -05:00
Merge pull request #337 from whiteout-io/dev/WO-964
[WO-964] Do not wait for next watch timer for ui update and general clea...
This commit is contained in:
commit
e5e1c118be
@ -53,9 +53,13 @@ var ReadCtrl = function($scope, $location, $q, email, invitation, outbox, pgp, k
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.decrypt = function(message) {
|
$scope.decrypt = function(message) {
|
||||||
|
return $q(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
}).then(function() {
|
||||||
return email.decryptBody({
|
return email.decryptBody({
|
||||||
message: message
|
message: message
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getKeyId = function(address) {
|
$scope.getKeyId = function(address) {
|
||||||
|
@ -53,8 +53,7 @@ ngModule.directive('frameLoad', function($window) {
|
|||||||
if (open) {
|
if (open) {
|
||||||
// trigger rendering of iframe
|
// trigger rendering of iframe
|
||||||
// otherwise scale to fit would not compute correct dimensions on mobile
|
// otherwise scale to fit would not compute correct dimensions on mobile
|
||||||
displayText(scope.state.mailList.selected ? scope.state.mailList.selected.body : undefined);
|
displayContent();
|
||||||
displayHtml(scope.state.mailList.selected ? scope.state.mailList.selected.html : undefined);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -84,46 +83,39 @@ ngModule.directive('frameLoad', function($window) {
|
|||||||
|
|
||||||
iframe.onload = function() {
|
iframe.onload = function() {
|
||||||
// set listeners
|
// set listeners
|
||||||
scope.$watch('state.mailList.selected.body', displayText);
|
scope.$watch('state.mailList.selected.body', displayContent);
|
||||||
scope.$watch('state.mailList.selected.html', displayHtml);
|
scope.$watch('state.mailList.selected.html', displayContent);
|
||||||
// display initial message body
|
// display initial message body
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
};
|
};
|
||||||
|
|
||||||
function displayText(body) {
|
function displayContent() {
|
||||||
var mail = scope.state.mailList.selected;
|
var mail = scope.state.mailList.selected;
|
||||||
|
|
||||||
if (mail && mail.encrypted && !mail.decrypted) {
|
if (!mail) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mail.encrypted && !mail.decrypted) {
|
||||||
// decrypt current mail
|
// decrypt current mail
|
||||||
scope.decrypt(mail);
|
scope.decrypt(mail).then(function() {
|
||||||
return;
|
if (scope.state.mailList.selected === mail && mail.decrypted) {
|
||||||
|
// decrypted mail is still selected, immidiately show body
|
||||||
|
displayContent();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (mail && mail.html) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resetWidth();
|
|
||||||
|
|
||||||
// send text body for rendering in iframe
|
|
||||||
iframe.contentWindow.postMessage({
|
|
||||||
text: body
|
|
||||||
}, '*');
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayHtml(html) {
|
|
||||||
if (!html) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetWidth();
|
resetWidth();
|
||||||
|
|
||||||
|
if (mail.html) {
|
||||||
// if there are image tags in the html?
|
// if there are image tags in the html?
|
||||||
var hasImages = /<img[^>]+\bsrc=['"][^'">]+['"]/ig.test(html);
|
var hasImages = /<img[^>]+\bsrc=['"][^'">]+['"]/ig.test(mail.html);
|
||||||
scope.showImageButton = hasImages;
|
scope.showImageButton = hasImages;
|
||||||
|
|
||||||
iframe.contentWindow.postMessage({
|
iframe.contentWindow.postMessage({
|
||||||
html: html,
|
html: mail.html,
|
||||||
removeImages: hasImages // avoids doing unnecessary work on the html
|
removeImages: hasImages // avoids doing unnecessary work on the html
|
||||||
}, '*');
|
}, '*');
|
||||||
|
|
||||||
@ -133,11 +125,17 @@ ngModule.directive('frameLoad', function($window) {
|
|||||||
scope.displayImages = function() {
|
scope.displayImages = function() {
|
||||||
scope.showImageButton = false;
|
scope.showImageButton = false;
|
||||||
iframe.contentWindow.postMessage({
|
iframe.contentWindow.postMessage({
|
||||||
html: html,
|
html: mail.html,
|
||||||
removeImages: false
|
removeImages: false
|
||||||
}, '*');
|
}, '*');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
} else if (mail.body) {
|
||||||
|
iframe.contentWindow.postMessage({
|
||||||
|
text: mail.body
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the iframe width to the original (min-width:100%)
|
// reset the iframe width to the original (min-width:100%)
|
||||||
|
Loading…
Reference in New Issue
Block a user