aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/info-main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-07 02:55:48 -0500
committerGitHub <noreply@github.com>2024-02-07 07:55:48 +0000
commitdc22c0260e55121b2930f8bf8761271ba977503f (patch)
tree1c5cf6d59fb600dfc03e46f11d3fba3dfb30c8f1 /ext/js/pages/info-main.js
parent376bac7195bf2114da8b234ffa64af9751b4466d (diff)
Update application init process (#634)
Diffstat (limited to 'ext/js/pages/info-main.js')
-rw-r--r--ext/js/pages/info-main.js83
1 files changed, 36 insertions, 47 deletions
diff --git a/ext/js/pages/info-main.js b/ext/js/pages/info-main.js
index ca5094b1..7d7d56a5 100644
--- a/ext/js/pages/info-main.js
+++ b/ext/js/pages/info-main.js
@@ -17,7 +17,6 @@
*/
import {Application} from '../application.js';
-import {log} from '../core/logger.js';
import {promiseTimeout} from '../core/utilities.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
@@ -116,59 +115,49 @@ async function showDictionaryInfo(api) {
container.appendChild(fragment);
}
-/** Entry point. */
-async function main() {
- try {
- const documentFocusController = new DocumentFocusController();
- documentFocusController.prepare();
-
- const manifest = chrome.runtime.getManifest();
- const language = chrome.i18n.getUILanguage();
-
- const application = new Application();
- await application.prepare();
+await Application.main(async (application) => {
+ const documentFocusController = new DocumentFocusController();
+ documentFocusController.prepare();
- const {userAgent} = navigator;
- const {name, version} = manifest;
- const {browser, platform: {os}} = await application.api.getEnvironmentInfo();
+ const manifest = chrome.runtime.getManifest();
+ const language = chrome.i18n.getUILanguage();
- /** @type {HTMLLinkElement} */
- const thisVersionLink = querySelectorNotNull(document, '#release-notes-this-version-link');
- const {hrefFormat} = thisVersionLink.dataset;
- thisVersionLink.href = typeof hrefFormat === 'string' ? hrefFormat.replace(/\{version\}/g, version) : '';
+ const {userAgent} = navigator;
+ const {name, version} = manifest;
+ const {browser, platform: {os}} = await application.api.getEnvironmentInfo();
- /** @type {HTMLElement} */
- const versionElement = querySelectorNotNull(document, '#version');
- /** @type {HTMLElement} */
- const browserElement = querySelectorNotNull(document, '#browser');
- /** @type {HTMLElement} */
- const platformElement = querySelectorNotNull(document, '#platform');
- /** @type {HTMLElement} */
- const languageElement = querySelectorNotNull(document, '#language');
- /** @type {HTMLElement} */
- const userAgentElement = querySelectorNotNull(document, '#user-agent');
+ /** @type {HTMLLinkElement} */
+ const thisVersionLink = querySelectorNotNull(document, '#release-notes-this-version-link');
+ const {hrefFormat} = thisVersionLink.dataset;
+ thisVersionLink.href = typeof hrefFormat === 'string' ? hrefFormat.replace(/\{version\}/g, version) : '';
- versionElement.textContent = `${name} ${version}`;
- browserElement.textContent = getBrowserDisplayName(browser);
- platformElement.textContent = getOperatingSystemDisplayName(os);
- languageElement.textContent = `${language}`;
- userAgentElement.textContent = userAgent;
+ /** @type {HTMLElement} */
+ const versionElement = querySelectorNotNull(document, '#version');
+ /** @type {HTMLElement} */
+ const browserElement = querySelectorNotNull(document, '#browser');
+ /** @type {HTMLElement} */
+ const platformElement = querySelectorNotNull(document, '#platform');
+ /** @type {HTMLElement} */
+ const languageElement = querySelectorNotNull(document, '#language');
+ /** @type {HTMLElement} */
+ const userAgentElement = querySelectorNotNull(document, '#user-agent');
- showAnkiConnectInfo(application.api);
- showDictionaryInfo(application.api);
+ versionElement.textContent = `${name} ${version}`;
+ browserElement.textContent = getBrowserDisplayName(browser);
+ platformElement.textContent = getOperatingSystemDisplayName(os);
+ languageElement.textContent = `${language}`;
+ userAgentElement.textContent = userAgent;
- const settingsController = new SettingsController(application);
- await settingsController.prepare();
+ showAnkiConnectInfo(application.api);
+ showDictionaryInfo(application.api);
- const backupController = new BackupController(settingsController, null);
- await backupController.prepare();
+ const settingsController = new SettingsController(application);
+ await settingsController.prepare();
- await promiseTimeout(100);
+ const backupController = new BackupController(settingsController, null);
+ await backupController.prepare();
- document.documentElement.dataset.loaded = 'true';
- } catch (e) {
- log.error(e);
- }
-}
+ await promiseTimeout(100);
-await main();
+ document.documentElement.dataset.loaded = 'true';
+});