From 9deef06bf2caaf766a512bda5a685b332c8ab9f3 Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Sat, 30 Dec 2023 03:10:49 +0100 Subject: [PATCH] I think this is it --- lib.ts | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib.ts b/lib.ts index 165f3cf..57acacd 100644 --- a/lib.ts +++ b/lib.ts @@ -7,9 +7,11 @@ const l10n = require('./locale/en-US/zotero-edtechhub.ftl') Services.wm.addListener({ onOpenWindow: xulWindow => { const win: Window = xulWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow) - win.addEventListener('load', function listener() { // eslint-disable-line prefer-arrow/prefer-arrow-functions - Zotero.EdTechHub?.ui() - }, false) + switch (win.location.href) { + case 'chrome://zotero/content/standalone/standalone.xul': + case 'chrome://zotero/content/zoteroPane.xhtml': + Zotero.EdTechHub?.ui('new window') + } }, // onCloseWindow: () => { }, // onWindowTitleChange: _xulWindow => { }, @@ -230,7 +232,8 @@ class EdTechHubMain { public translators: { file: string, translatorID: string }[] = [] public uninstalled = false - ui() { + ui(reason: string) { + debug(`installing UI: ${reason}`) const win = Zotero.getMainWindow() const doc = win.document @@ -323,17 +326,6 @@ class EdTechHubMain { } async startup() { - try { - debug('starting...') - await this.start_up() - debug('started') - } - catch (err) { - debug('failed to start', err) - } - } - - async start_up() { const ready = Zotero.Promise.defer() this.ready = ready.promise @@ -438,7 +430,7 @@ class EdTechHubMain { ready.resolve(true) - this.ui() + this.ui('startup') } shutdown() {