Skip to content

Commit

Permalink
fix(mail(js)): resolve draft mailbox from popup window
Browse files Browse the repository at this point in the history
Fixes #5442
  • Loading branch information
cgx committed Dec 13, 2021
1 parent 2541210 commit 25c69aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
14 changes: 10 additions & 4 deletions UI/WebServerResources/js/Mailer/Account.service.js
Expand Up @@ -25,9 +25,12 @@
identity.textSignature = _.map(element.contents(), 'textContent').join(' ').trim();
}
});
_.forEach(this.$mailboxes, function(mailboxData, i, mailboxes) {
mailboxes[i] = new Account.$Mailbox(_this, mailboxData);
});
if (this.$mailboxes) {
// Create instances of Mailbox
Account.$Mailbox.$unwrapCollection(this, Account.$q.when({ mailboxes: this.$mailboxes })).then(function(collection) {
_this.$mailboxes = collection;
});
}
}
else {
// The promise will be unwrapped first
Expand Down Expand Up @@ -362,6 +365,9 @@
};
mailbox = _find(this.$mailboxes);

if (mailbox == null)
throw Error('No mailbox found matching path ' + path);

return mailbox;
};

Expand Down Expand Up @@ -565,7 +571,7 @@

if (deep) {
_.forEach(this.$mailboxes, function(mailbox) {
mailboxes.push(mailbox.$omit());
mailboxes.push(mailbox.$omit(deep));
});
account.$mailboxes = mailboxes;
}
Expand Down
15 changes: 13 additions & 2 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Expand Up @@ -991,8 +991,16 @@
* @desc Return a sanitized object used to send to the server.
* @return an object literal copy of the Mailbox instance
*/
Mailbox.prototype.$omit = function() {
var mailbox = {};
Mailbox.prototype.$omit = function(deep) {
var mailbox = {},
_visit = function(children) {
var childrenArray = [];
_.forEach(children, function(o) {
childrenArray.push(o.$omit(deep));
});
return childrenArray;
};

angular.forEach(this, function(value, key) {
if (key != 'constructor' &&
key != 'children' &&
Expand All @@ -1003,6 +1011,9 @@
mailbox[key] = value;
}
});
if (deep && this.children) {
mailbox.children = _visit(this.children);
}
return mailbox;
};

Expand Down
2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Mailer/Mailer.popup.js
Expand Up @@ -175,7 +175,7 @@
$window.opener.$mailboxController.selectedFolder.path == mailboxId) {
// The message mailbox is opened in the parent window
mailbox = new Mailbox(stateAccount,
$window.opener.$mailboxController.selectedFolder.$omit());
$window.opener.$mailboxController.selectedFolder.$omit(true));
}
}

Expand Down
3 changes: 2 additions & 1 deletion UI/WebServerResources/js/Mailer/Message.service.js
Expand Up @@ -132,7 +132,8 @@
_this.flags.splice(i, 1,'_' + flag);
}
});
this.isread = !!this.isread;
// isread will be undefined when composing a new message -- assume unseen flag is not set.
this.isread = angular.isDefined(this.isread) ? !!this.isread : true;
};

/**
Expand Down

0 comments on commit 25c69aa

Please sign in to comment.