Skip to content

Commit

Permalink
flash all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed May 15, 2024
1 parent 035cb64 commit 22631bb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions content/translators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint
public worker: ChromeWorker

public ready = new Deferred<boolean>()
private installing = ''

constructor() {
Object.assign(this, { byLabel, byId, bySlug })
Expand Down Expand Up @@ -105,7 +104,7 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint
])
}
catch (err) {
flash('Failed to load translators', `BBT could not load its translators, load stalled at ${this.installing}`)
flash('Failed to load translators', 'BBT could not load its translators, installation timed out')
}

log.debug('translators startup: finished')
Expand Down Expand Up @@ -532,10 +531,10 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint
}

private async installTranslators() {
this.installing = 'waiting for Zotero.Translators.init()'
flash('installing translators', 'waiting for Zotero.Translators.init()')
await Zotero.Translators.init()

this.installing = 'loading BBT translators'
flash('installing translators', 'loading BBT translators')
const reinit: { header: Translator.Header, code: string }[] = []
// fetch from resource because that has the hash
const headers: Translator.Header[] = Headers
Expand All @@ -545,16 +544,16 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint
// workaround for mem limitations on Windows
if (!is7 && typeof header.displayOptions?.worker === 'boolean') header.displayOptions.worker = !!Zotero.isWin
if (code = await this.install(header)) {
this.installing = `scheduling ${header.label} for re-init`
flash('installing translators', `scheduling ${header.label} for re-init`)
reinit.push({ header, code })
}
}

if (reinit.length) {
this.installing = `scheduling ${reinit.length} for re-init`
flash('installing translators', `scheduling ${reinit.length} for re-init`)
await Zotero.Translators.reinit()
}
this.installing = 'done'
flash('installing translators', 'done')
}

public async install(header: Translator.Header): Promise<string> {
Expand Down

0 comments on commit 22631bb

Please sign in to comment.