Skip to content

Commit

Permalink
simplify language controller
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Feb 16, 2024
1 parent 1d7a349 commit 000bfa7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions ext/js/pages/settings/languages-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import {EventListenerCollection} from '../../core/event-listener-collection.js';
import {querySelectorNotNull} from '../../dom/query-selector.js';

export class LanguagesController {
Expand All @@ -26,23 +25,21 @@ export class LanguagesController {
constructor(settingsController) {
/** @type {import('./settings-controller.js').SettingsController} */
this._settingsController = settingsController;
/** @type {import('language').LanguageSummary[]} */
this._languages = [];
/** @type {EventListenerCollection} */
this._eventListeners = new EventListenerCollection();
}

/** */
async prepare() {
this._languages = await this._settingsController.application.api.getLanguageSummaries();
this._languages.sort((a, b) => a.iso.localeCompare(b.iso, 'en'));
this._fillSelect();
const languages = await this._settingsController.application.api.getLanguageSummaries();
languages.sort((a, b) => a.iso.localeCompare(b.iso, 'en'));
this._fillSelect(languages);
}

/** */
_fillSelect() {
/**
* @param {import('language').LanguageSummary[]} languages
*/
_fillSelect(languages) {
const selectElement = querySelectorNotNull(document, '#language-select');
for (const {iso, name} of this._languages) {
for (const {iso, name} of languages) {
const option = document.createElement('option');
option.value = iso;
option.text = `(${iso}) ${name}`;
Expand Down

0 comments on commit 000bfa7

Please sign in to comment.