(js) Handle corrupted JSON data in Mail module

The Mail module will now be loaded even if the JSON representing the
list of expanded mailboxes is not a properly formatted.
pull/218/merge
Francis Lachapelle 2017-10-31 13:25:51 -04:00
parent c7e9b0e3a6
commit ccb1439c84
1 changed files with 11 additions and 3 deletions

View File

@ -146,11 +146,19 @@
});
};
if (Account.$Preferences.settings.Mail.ExpandedFolders) {
if (angular.isString(Account.$Preferences.settings.Mail.ExpandedFolders))
if (angular.isString(Account.$Preferences.settings.Mail.ExpandedFolders)) {
// Backward compatibility support
expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders);
else
try {
expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders);
}
catch (e) {
Account.$log.warn("Can't parse list of expanded folders. String was: " +
Account.$Preferences.settings.Mail.ExpandedFolders);
}
}
else {
expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders;
}
_this.$expanded = (expandedFolders.indexOf('/' + _this.id) >= 0);
if (expandedFolders.length > 0) {
_visit(_this.$mailboxes);