summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/backup-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-11 14:15:08 -0400
committerGitHub <noreply@github.com>2020-09-11 14:15:08 -0400
commitf168efb69c0387da0be4e9f2807fd9074992346f (patch)
tree102d68d73e5914848b3d795238f9478dd79bd7b9 /ext/bg/js/settings/backup-controller.js
parenta1729eb9aee9426cc9b543c865a53e843ae5f487 (diff)
OptionsUtil refactor / options default values (#807)
* Replace _readFile with _fetchAsset for consistency with Backend * Fix error messages * Make OptionsUtil non-static * Update how default options are assigned * Add createValidatingProxy * Add validate, update _onApiSetAllSettings * Remove unused api.optionsSchemaGet * Remove Backend._optionsSchema * Update OptionsUtil to create its own JsonSchemaValidator * Rename Backend._optionsSchemaValidator * Make getDefault non-async
Diffstat (limited to 'ext/bg/js/settings/backup-controller.js')
-rw-r--r--ext/bg/js/settings/backup-controller.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/bg/js/settings/backup-controller.js b/ext/bg/js/settings/backup-controller.js
index ac1294e7..08ee7070 100644
--- a/ext/bg/js/settings/backup-controller.js
+++ b/ext/bg/js/settings/backup-controller.js
@@ -26,9 +26,12 @@ class BackupController {
this._settingsExportToken = null;
this._settingsExportRevoke = null;
this._currentVersion = 0;
+ this._optionsUtil = new OptionsUtil();
}
- prepare() {
+ async prepare() {
+ await this._optionsUtil.prepare();
+
document.querySelector('#settings-export').addEventListener('click', this._onSettingsExportClick.bind(this), false);
document.querySelector('#settings-import').addEventListener('click', this._onSettingsImportClick.bind(this), false);
document.querySelector('#settings-import-file').addEventListener('change', this._onSettingsImportFileChange.bind(this), false);
@@ -140,7 +143,11 @@ class BackupController {
// Importing
async _settingsImportSetOptionsFull(optionsFull) {
- await this._settingsController.setAllSettings(optionsFull);
+ try {
+ await this._settingsController.setAllSettings(optionsFull);
+ } catch (e) {
+ yomichan.logError(e);
+ }
}
_showSettingsImportError(error) {
@@ -322,7 +329,7 @@ class BackupController {
}
// Upgrade options
- optionsFull = await OptionsUtil.update(optionsFull);
+ optionsFull = await this._optionsUtil.update(optionsFull);
// Check for warnings
const sanitizationWarnings = this._settingsImportSanitizeOptions(optionsFull, true);
@@ -368,7 +375,7 @@ class BackupController {
$('#settings-reset-modal').modal('hide');
// Get default options
- const optionsFull = await OptionsUtil.getDefault();
+ const optionsFull = this._optionsUtil.getDefault();
// Assign options
await this._settingsImportSetOptionsFull(optionsFull);