(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.
This commit is contained in:
Francis Lachapelle 2017-10-31 13:25:51 -04:00
parent c7e9b0e3a6
commit ccb1439c84

View file

@ -146,11 +146,19 @@
}); });
}; };
if (Account.$Preferences.settings.Mail.ExpandedFolders) { 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 // Backward compatibility support
expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders); try {
else 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; expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders;
}
_this.$expanded = (expandedFolders.indexOf('/' + _this.id) >= 0); _this.$expanded = (expandedFolders.indexOf('/' + _this.id) >= 0);
if (expandedFolders.length > 0) { if (expandedFolders.length > 0) {
_visit(_this.$mailboxes); _visit(_this.$mailboxes);