Skip to content

Commit

Permalink
style: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xiCO2k committed Sep 8, 2022
1 parent b00236f commit 0d381f8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ export class I18n {
private activeMessages: object = reactive({})

// Stores the abort controller for the load promises.
private abortController: AbortController;
private abortController: AbortController

/**
* Creates a new instance of the I18n class, applying default options
*/
constructor(options: OptionsInterface = {}) {
this.options = { ...DEFAULT_OPTIONS, ...options }

this.load();
this.load()
}

/**
Expand All @@ -147,7 +147,7 @@ export class I18n {
this.options = { ...this.options, ...options }

if (forceLoad) {
this.load();
this.load()
}

return this
Expand Down Expand Up @@ -181,9 +181,9 @@ export class I18n {
* Loads the language file.
*/
loadLanguageAsync(lang: string, dashLangTry = false, ignoreAbort = false): Promise<string | void> {
if (! ignoreAbort) {
this.abortController?.abort();
this.abortController = new AbortController();
if (!ignoreAbort) {
this.abortController?.abort()
this.abortController = new AbortController()
}

const loadedLang: LanguageInterface = I18n.loaded.find((row) => row.lang === lang)
Expand All @@ -194,14 +194,13 @@ export class I18n {

return new Promise((resolve, reject) => {
this.abortController.signal.addEventListener('abort', () => {
resolve();
});
resolve()
})

this.resolveLangAsync(this.options.resolve, lang).then(({ default: messages }) => {
resolve(this.applyLanguage(lang, messages, dashLangTry, this.loadLanguageAsync));
});
});

resolve(this.applyLanguage(lang, messages, dashLangTry, this.loadLanguageAsync))
})
})
}

/**
Expand Down

0 comments on commit 0d381f8

Please sign in to comment.