diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-07 02:55:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-07 07:55:48 +0000 |
commit | dc22c0260e55121b2930f8bf8761271ba977503f (patch) | |
tree | 1c5cf6d59fb600dfc03e46f11d3fba3dfb30c8f1 /ext/js/pages/settings/popup-preview-frame-main.js | |
parent | 376bac7195bf2114da8b234ffa64af9751b4466d (diff) |
Update application init process (#634)
Diffstat (limited to 'ext/js/pages/settings/popup-preview-frame-main.js')
-rw-r--r-- | ext/js/pages/settings/popup-preview-frame-main.js | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/ext/js/pages/settings/popup-preview-frame-main.js b/ext/js/pages/settings/popup-preview-frame-main.js index fd08bf1d..cffbf01b 100644 --- a/ext/js/pages/settings/popup-preview-frame-main.js +++ b/ext/js/pages/settings/popup-preview-frame-main.js @@ -18,37 +18,26 @@ import {PopupFactory} from '../../app/popup-factory.js'; import {Application} from '../../application.js'; -import {log} from '../../core/logger.js'; import {HotkeyHandler} from '../../input/hotkey-handler.js'; import {PopupPreviewFrame} from './popup-preview-frame.js'; -/** Entry point. */ -async function main() { - try { - const application = new Application(); - await application.prepare(); - - const {tabId, frameId} = await application.api.frameInformationGet(); - if (typeof tabId === 'undefined') { - throw new Error('Failed to get tabId'); - } - if (typeof frameId === 'undefined') { - throw new Error('Failed to get frameId'); - } - - const hotkeyHandler = new HotkeyHandler(); - hotkeyHandler.prepare(application.crossFrame); +await Application.main(async (application) => { + const {tabId, frameId} = await application.api.frameInformationGet(); + if (typeof tabId === 'undefined') { + throw new Error('Failed to get tabId'); + } + if (typeof frameId === 'undefined') { + throw new Error('Failed to get frameId'); + } - const popupFactory = new PopupFactory(application, frameId); - popupFactory.prepare(); + const hotkeyHandler = new HotkeyHandler(); + hotkeyHandler.prepare(application.crossFrame); - const preview = new PopupPreviewFrame(application, tabId, frameId, popupFactory, hotkeyHandler); - await preview.prepare(); + const popupFactory = new PopupFactory(application, frameId); + popupFactory.prepare(); - document.documentElement.dataset.loaded = 'true'; - } catch (e) { - log.error(e); - } -} + const preview = new PopupPreviewFrame(application, tabId, frameId, popupFactory, hotkeyHandler); + await preview.prepare(); -await main(); + document.documentElement.dataset.loaded = 'true'; +}); |