(js) Fix restore of mailboxes expansion states
parent
d61a9d0b80
commit
7c4b1b36cf
1
NEWS
1
NEWS
|
@ -14,6 +14,7 @@ Bug fixes
|
|||
- [web] fixed event classification icon (private/confidential) in day/week/multicolumn views
|
||||
- [web] fixed display of mailboxes list on mobiles (#3654)
|
||||
- [web] restored Catalan and Slovak translations (#3687)
|
||||
- [web] fixed restore of mailboxes expansion state when multiple IMAP accounts are configured
|
||||
|
||||
3.1.0 (2016-05-18)
|
||||
------------------
|
||||
|
|
|
@ -86,6 +86,8 @@
|
|||
o.id = i;
|
||||
collection[i] = new Account(o);
|
||||
});
|
||||
Account.$accounts = collection;
|
||||
|
||||
return collection;
|
||||
};
|
||||
|
||||
|
@ -139,7 +141,10 @@
|
|||
* @function $flattenMailboxes
|
||||
* @memberof Account.prototype
|
||||
* @desc Get a flatten array of the mailboxes.
|
||||
* @param {object} [options] - force a reload
|
||||
* @param {object} [options] - the following boolean attributes are available:
|
||||
* - reload: rebuild the flatten array of mailboxes from the original tree representation (this.$mailboxes)
|
||||
* - all: return all mailboxes, ignoring their expanstion state
|
||||
* - saveState: save expansion state of mailboxes to the server
|
||||
* @returns an array of Mailbox instances
|
||||
*/
|
||||
Account.prototype.$flattenMailboxes = function(options) {
|
||||
|
@ -163,12 +168,15 @@
|
|||
if (!options || !options.all) {
|
||||
_this.$$flattenMailboxes = allMailboxes;
|
||||
if (options && options.saveState) {
|
||||
_.reduce(allMailboxes, function(expandedFolders, mailbox) {
|
||||
if (mailbox.$expanded) {
|
||||
expandedFolders.push('/' + mailbox.id);
|
||||
}
|
||||
return expandedFolders;
|
||||
}, expandedMailboxes);
|
||||
// Save expansion state of mailboxes to the server
|
||||
_.forEach(Account.$accounts, function(account) {
|
||||
_.reduce(account.$$flattenMailboxes, function(expandedFolders, mailbox) {
|
||||
if (mailbox.$expanded) {
|
||||
expandedFolders.push('/' + mailbox.id);
|
||||
}
|
||||
return expandedFolders;
|
||||
}, expandedMailboxes);
|
||||
});
|
||||
Account.$$resource.post(null, 'saveFoldersState', expandedMailboxes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue