fix(mail(js)): resolve draft mailbox from popup window

Fixes #5442
This commit is contained in:
Francis Lachapelle
2021-12-13 14:30:39 -05:00
parent 254121052d
commit 25c69aaef4
4 changed files with 26 additions and 8 deletions
@@ -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
@@ -362,6 +365,9 @@
};
mailbox = _find(this.$mailboxes);
if (mailbox == null)
throw Error('No mailbox found matching path ' + path);
return mailbox;
};
@@ -565,7 +571,7 @@
if (deep) {
_.forEach(this.$mailboxes, function(mailbox) {
mailboxes.push(mailbox.$omit());
mailboxes.push(mailbox.$omit(deep));
});
account.$mailboxes = mailboxes;
}
@@ -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' &&
@@ -1003,6 +1011,9 @@
mailbox[key] = value;
}
});
if (deep && this.children) {
mailbox.children = _visit(this.children);
}
return mailbox;
};
@@ -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));
}
}
@@ -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;
};
/**