summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-30 16:23:56 -0400
committerGitHub <noreply@github.com>2020-05-30 16:23:56 -0400
commit976a200ffc65e94f0246392f6b29505f1eb4f16c (patch)
treebc33257947294a1ffbccfb036203c0a2f842670d /ext/bg/js/backend.js
parentc8810bc92972d14858cdad637eb0a078cae46349 (diff)
Backup update (#582)
* Add function to assign all settings * Update how settings backups are restored * Remove page reload * Update profile index after importing
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 80b00d5f..08ce82a2 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -122,7 +122,8 @@ class Backend {
['logIndicatorClear', {async: false, contentScript: true, handler: this._onApiLogIndicatorClear.bind(this)}],
['createActionPort', {async: false, contentScript: true, handler: this._onApiCreateActionPort.bind(this)}],
['modifySettings', {async: true, contentScript: true, handler: this._onApiModifySettings.bind(this)}],
- ['getSettings', {async: false, contentScript: true, handler: this._onApiGetSettings.bind(this)}]
+ ['getSettings', {async: false, contentScript: true, handler: this._onApiGetSettings.bind(this)}],
+ ['setAllSettings', {async: true, contentScript: false, handler: this._onApiSetAllSettings.bind(this)}]
]);
this._messageHandlersWithProgress = new Map([
['importDictionaryArchive', {async: true, contentScript: false, handler: this._onApiImportDictionaryArchive.bind(this)}],
@@ -317,15 +318,6 @@ class Backend {
return useSchema ? JsonSchema.createProxy(options, this.optionsSchema) : options;
}
- setFullOptions(options) {
- try {
- this.options = JsonSchema.getValidValueOrDefault(this.optionsSchema, utilIsolate(options));
- } catch (e) {
- // This shouldn't happen, but catch errors just in case of bugs
- yomichan.logError(e);
- }
- }
-
getOptions(optionsContext, useSchema=false) {
return this.getProfile(optionsContext, useSchema).options;
}
@@ -860,6 +852,11 @@ class Backend {
return results;
}
+ async _onApiSetAllSettings({value, source}) {
+ this.options = JsonSchema.getValidValueOrDefault(this.optionsSchema, value);
+ await this._onApiOptionsSave({source});
+ }
+
// Command handlers
_createActionListenerPort(port, sender, handlers) {