From c1d219751e20e28f75c44ec0fe7e200b412f4d14 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 4 Feb 2024 22:43:25 +0100 Subject: [PATCH] simplify LanguageOptions --- ext/js/pages/settings/languages-controller.js | 14 +++++++------- types/ext/settings.d.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/js/pages/settings/languages-controller.js b/ext/js/pages/settings/languages-controller.js index befda65a15..7556350977 100755 --- a/ext/js/pages/settings/languages-controller.js +++ b/ext/js/pages/settings/languages-controller.js @@ -56,16 +56,16 @@ export class LanguagesController { async _updateOptions() { const options = await this._settingsController.getOptions(); const {general: {language}} = options; + if (!options.languages[language]) { + /** @type {import('settings').LanguageOptions} */ + const defaultOptions = { + textPreprocessors: {} + }; await this._settingsController.modifyProfileSettings([{ action: 'set', - path: 'languages', - value: { - ...options.languages, - [language]: { - textPreprocessors: {} - } - } + path: `languages[${JSON.stringify(language)}]`, + value: defaultOptions }]); } } diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index 623f66b1d7..1a740ed2ab 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -348,7 +348,7 @@ export type TextPreprocessorsOptions = { }; export type LanguageOptions = { - textPreprocessors?: TextPreprocessorsOptions; + textPreprocessors: TextPreprocessorsOptions; }; export type LanguageOptionsObjectMap = {