summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/settings-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages/settings/settings-controller.js')
-rw-r--r--ext/js/pages/settings/settings-controller.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/ext/js/pages/settings/settings-controller.js b/ext/js/pages/settings/settings-controller.js
index 49fa9c9e..3f389271 100644
--- a/ext/js/pages/settings/settings-controller.js
+++ b/ext/js/pages/settings/settings-controller.js
@@ -22,14 +22,18 @@ import {generateId, isObject} from '../../core/utilities.js';
import {OptionsUtil} from '../../data/options-util.js';
import {getAllPermissions} from '../../data/permissions-util.js';
import {HtmlTemplateCollection} from '../../dom/html-template-collection.js';
-import {yomitan} from '../../yomitan.js';
/**
* @augments EventDispatcher<import('settings-controller').Events>
*/
export class SettingsController extends EventDispatcher {
- constructor() {
+ /**
+ * @param {import('../../application.js').Application} application
+ */
+ constructor(application) {
super();
+ /** @type {import('../../application.js').Application} */
+ this._application = application;
/** @type {number} */
this._profileIndex = 0;
/** @type {string} */
@@ -43,6 +47,11 @@ export class SettingsController extends EventDispatcher {
this._templates.load(document);
}
+ /** @type {import('../../application.js').Application} */
+ get application() {
+ return this._application;
+ }
+
/** @type {string} */
get source() {
return this._source;
@@ -60,7 +69,7 @@ export class SettingsController extends EventDispatcher {
/** */
async prepare() {
- yomitan.on('optionsUpdated', this._onOptionsUpdated.bind(this));
+ this._application.on('optionsUpdated', this._onOptionsUpdated.bind(this));
if (this._canObservePermissionsChanges()) {
chrome.permissions.onAdded.addListener(this._onPermissionsChanged.bind(this));
chrome.permissions.onRemoved.addListener(this._onPermissionsChanged.bind(this));
@@ -82,14 +91,14 @@ export class SettingsController extends EventDispatcher {
*/
async getOptions() {
const optionsContext = this.getOptionsContext();
- return await yomitan.api.optionsGet(optionsContext);
+ return await this._application.api.optionsGet(optionsContext);
}
/**
* @returns {Promise<import('settings').Options>}
*/
async getOptionsFull() {
- return await yomitan.api.optionsGetFull();
+ return await this._application.api.optionsGetFull();
}
/**
@@ -97,7 +106,7 @@ export class SettingsController extends EventDispatcher {
*/
async setAllSettings(value) {
const profileIndex = value.profileCurrent;
- await yomitan.api.setAllSettings(value, this._source);
+ await this._application.api.setAllSettings(value, this._source);
this._setProfileIndex(profileIndex, true);
}
@@ -171,7 +180,7 @@ export class SettingsController extends EventDispatcher {
* @returns {Promise<import('dictionary-importer').Summary[]>}
*/
async getDictionaryInfo() {
- return await yomitan.api.getDictionaryInfo();
+ return await this._application.api.getDictionaryInfo();
}
/**
@@ -279,7 +288,7 @@ export class SettingsController extends EventDispatcher {
this._modifyOptionsScope(target2);
return target2;
});
- return await yomitan.api.getSettings(targets2);
+ return await this._application.api.getSettings(targets2);
}
/**
@@ -294,7 +303,7 @@ export class SettingsController extends EventDispatcher {
this._modifyOptionsScope(target2);
return target2;
});
- return await yomitan.api.modifySettings(targets2, this._source);
+ return await this._application.api.modifySettings(targets2, this._source);
}
/**