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/welcome-main.js | |
parent | 376bac7195bf2114da8b234ffa64af9751b4466d (diff) |
Update application init process (#634)
Diffstat (limited to 'ext/js/pages/welcome-main.js')
-rw-r--r-- | ext/js/pages/welcome-main.js | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/ext/js/pages/welcome-main.js b/ext/js/pages/welcome-main.js index 030d2826..82afaacb 100644 --- a/ext/js/pages/welcome-main.js +++ b/ext/js/pages/welcome-main.js @@ -17,7 +17,6 @@ */ import {Application} from '../application.js'; -import {log} from '../core/logger.js'; import {DocumentFocusController} from '../dom/document-focus-controller.js'; import {querySelectorNotNull} from '../dom/query-selector.js'; import {ExtensionContentController} from './common/extension-content-controller.js'; @@ -50,64 +49,54 @@ async function setupGenericSettingsController(genericSettingController) { await genericSettingController.refresh(); } -/** Entry point. */ -async function main() { - try { - const documentFocusController = new DocumentFocusController(); - documentFocusController.prepare(); +await Application.main(async (application) => { + const documentFocusController = new DocumentFocusController(); + documentFocusController.prepare(); - const extensionContentController = new ExtensionContentController(); - extensionContentController.prepare(); + const extensionContentController = new ExtensionContentController(); + extensionContentController.prepare(); - /** @type {HTMLElement} */ - const statusFooterElement = querySelectorNotNull(document, '.status-footer-container'); - const statusFooter = new StatusFooter(statusFooterElement); - statusFooter.prepare(); + /** @type {HTMLElement} */ + const statusFooterElement = querySelectorNotNull(document, '.status-footer-container'); + const statusFooter = new StatusFooter(statusFooterElement); + statusFooter.prepare(); - const application = new Application(); - await application.prepare(); + setupEnvironmentInfo(application.api); - setupEnvironmentInfo(application.api); + chrome.storage.session.get({'needsCustomTemplatesWarning': false}).then((result) => { + if (result.needsCustomTemplatesWarning) { + document.documentElement.dataset.warnCustomTemplates = 'true'; + chrome.storage.session.remove(['needsCustomTemplatesWarning']); + } + }); - chrome.storage.session.get({'needsCustomTemplatesWarning': false}).then((result) => { - if (result.needsCustomTemplatesWarning) { - document.documentElement.dataset.warnCustomTemplates = 'true'; - chrome.storage.session.remove(['needsCustomTemplatesWarning']); - } - }); + const preparePromises = []; - const preparePromises = []; + const modalController = new ModalController(); + modalController.prepare(); - const modalController = new ModalController(); - modalController.prepare(); + const settingsController = new SettingsController(application); + await settingsController.prepare(); - const settingsController = new SettingsController(application); - await settingsController.prepare(); + const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter); + dictionaryController.prepare(); - const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter); - dictionaryController.prepare(); + const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter); + dictionaryImportController.prepare(); - const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter); - dictionaryImportController.prepare(); + const genericSettingController = new GenericSettingController(settingsController); + preparePromises.push(setupGenericSettingsController(genericSettingController)); - const genericSettingController = new GenericSettingController(settingsController); - preparePromises.push(setupGenericSettingsController(genericSettingController)); + const simpleScanningInputController = new ScanInputsSimpleController(settingsController); + simpleScanningInputController.prepare(); - const simpleScanningInputController = new ScanInputsSimpleController(settingsController); - simpleScanningInputController.prepare(); + const recommendedPermissionsController = new RecommendedPermissionsController(settingsController); + recommendedPermissionsController.prepare(); - const recommendedPermissionsController = new RecommendedPermissionsController(settingsController); - recommendedPermissionsController.prepare(); + await Promise.all(preparePromises); - await Promise.all(preparePromises); + document.documentElement.dataset.loaded = 'true'; - document.documentElement.dataset.loaded = 'true'; - - const settingsDisplayController = new SettingsDisplayController(settingsController, modalController); - settingsDisplayController.prepare(); - } catch (e) { - log.error(e); - } -} - -await main(); + const settingsDisplayController = new SettingsDisplayController(settingsController, modalController); + settingsDisplayController.prepare(); +}); |