Skip to content

Commit

Permalink
Copy recommended dicts logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmaa committed Oct 29, 2024
1 parent 43f0b4e commit b744869
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ext/js/pages/settings/settings-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import {EventDispatcher} from '../../core/event-dispatcher.js';
import {EventListenerCollection} from '../../core/event-listener-collection.js';
import {fetchJson} from '../../core/fetch-utilities.js';
import {readResponseJson} from '../../core/json.js';
import {isObjectNotArray} from '../../core/object-utilities.js';
import {generateId} from '../../core/utilities.js';
import {OptionsUtil} from '../../data/options-util.js';
Expand Down Expand Up @@ -78,7 +78,21 @@ export class SettingsController extends EventDispatcher {
/** */
async prepare() {
await this._templates.loadFromFiles(['/templates-settings.html']);
this._recommendedSettingsByLanguage = await fetchJson('../../data/recommended-settings.json');
const url = '../../data/recommended-settings.json';
const response = await fetch(url, {
method: 'GET',
mode: 'no-cors',
cache: 'default',
credentials: 'omit',
redirect: 'follow',
referrerPolicy: 'no-referrer',
});
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status}`);
}

this._recommendedSettingsByLanguage = (await readResponseJson(response));

this._application.on('optionsUpdated', this._onOptionsUpdated.bind(this));
if (this._canObservePermissionsChanges()) {
chrome.permissions.onAdded.addListener(this._onPermissionsChanged.bind(this));
Expand Down

0 comments on commit b744869

Please sign in to comment.