(js) Improve popup window detection in mailer

Fixes #4518
This commit is contained in:
Francis Lachapelle
2018-07-31 09:11:45 -04:00
parent 0feddfc7af
commit 7f135e5323
2 changed files with 10 additions and 2 deletions
@@ -11,6 +11,8 @@
var vm = this, popupWindow = null, hotkeys = [];
this.$onInit = function() {
var isPopupWindow = false;
// Expose controller
$window.$messageController = vm;
@@ -30,9 +32,14 @@
_registerHotkeys(hotkeys);
// Detect if this is message appears in a separate window
try {
isPopupWindow = $window.opener && '$mailboxController' in $window.opener;
}
catch (e) {}
// One-way refresh of the parent window when modifying the message from a popup window.
if ($window.opener &&
'$mailboxController' in $window.opener) {
if (isPopupWindow) {
// Update the message flags. The message must be displayed in the parent window.
$scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) {
var ctrls;