summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings
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/settings
parent376bac7195bf2114da8b234ffa64af9751b4466d (diff)
Update application init process (#634)
Diffstat (limited to 'ext/js/pages/settings')
-rw-r--r--ext/js/pages/settings/popup-preview-frame-main.js43
-rw-r--r--ext/js/pages/settings/settings-main.js165
2 files changed, 93 insertions, 115 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';
+});
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js
index c3391173..dc4b36c9 100644
--- a/ext/js/pages/settings/settings-main.js
+++ b/ext/js/pages/settings/settings-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';
@@ -58,124 +57,114 @@ async function setupGenericSettingController(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();
- /** @type {?number} */
- let prepareTimer = window.setTimeout(() => {
- prepareTimer = null;
- document.documentElement.dataset.loadingStalled = 'true';
- }, 1000);
+ /** @type {?number} */
+ let prepareTimer = window.setTimeout(() => {
+ prepareTimer = null;
+ document.documentElement.dataset.loadingStalled = 'true';
+ }, 1000);
- const application = new Application();
- await application.prepare();
-
- if (prepareTimer !== null) {
- clearTimeout(prepareTimer);
- prepareTimer = null;
- }
- delete document.documentElement.dataset.loadingStalled;
-
- const preparePromises = [];
+ if (prepareTimer !== null) {
+ clearTimeout(prepareTimer);
+ prepareTimer = null;
+ }
+ delete document.documentElement.dataset.loadingStalled;
- const modalController = new ModalController();
- modalController.prepare();
+ const preparePromises = [];
- const settingsController = new SettingsController(application);
- await settingsController.prepare();
+ const modalController = new ModalController();
+ modalController.prepare();
- const persistentStorageController = new PersistentStorageController(application);
- persistentStorageController.prepare();
+ const settingsController = new SettingsController(application);
+ await settingsController.prepare();
- const storageController = new StorageController(persistentStorageController);
- storageController.prepare();
+ const persistentStorageController = new PersistentStorageController(application);
+ persistentStorageController.prepare();
- const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter);
- dictionaryController.prepare();
+ const storageController = new StorageController(persistentStorageController);
+ storageController.prepare();
- const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter);
- dictionaryImportController.prepare();
+ const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter);
+ dictionaryController.prepare();
- const genericSettingController = new GenericSettingController(settingsController);
- preparePromises.push(setupGenericSettingController(genericSettingController));
+ const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter);
+ dictionaryImportController.prepare();
- const audioController = new AudioController(settingsController, modalController);
- audioController.prepare();
+ const genericSettingController = new GenericSettingController(settingsController);
+ preparePromises.push(setupGenericSettingController(genericSettingController));
- const profileController = new ProfileController(settingsController, modalController);
- profileController.prepare();
+ const audioController = new AudioController(settingsController, modalController);
+ audioController.prepare();
- const settingsBackup = new BackupController(settingsController, modalController);
- settingsBackup.prepare();
+ const profileController = new ProfileController(settingsController, modalController);
+ profileController.prepare();
- const ankiController = new AnkiController(settingsController);
- ankiController.prepare();
+ const settingsBackup = new BackupController(settingsController, modalController);
+ settingsBackup.prepare();
- const ankiTemplatesController = new AnkiTemplatesController(settingsController, modalController, ankiController);
- ankiTemplatesController.prepare();
+ const ankiController = new AnkiController(settingsController);
+ ankiController.prepare();
- const popupPreviewController = new PopupPreviewController(settingsController);
- popupPreviewController.prepare();
+ const ankiTemplatesController = new AnkiTemplatesController(settingsController, modalController, ankiController);
+ ankiTemplatesController.prepare();
- const scanInputsController = new ScanInputsController(settingsController);
- scanInputsController.prepare();
+ const popupPreviewController = new PopupPreviewController(settingsController);
+ popupPreviewController.prepare();
- const simpleScanningInputController = new ScanInputsSimpleController(settingsController);
- simpleScanningInputController.prepare();
+ const scanInputsController = new ScanInputsController(settingsController);
+ scanInputsController.prepare();
- const nestedPopupsController = new NestedPopupsController(settingsController);
- nestedPopupsController.prepare();
+ const simpleScanningInputController = new ScanInputsSimpleController(settingsController);
+ simpleScanningInputController.prepare();
- const permissionsToggleController = new PermissionsToggleController(settingsController);
- permissionsToggleController.prepare();
+ const nestedPopupsController = new NestedPopupsController(settingsController);
+ nestedPopupsController.prepare();
- const secondarySearchDictionaryController = new SecondarySearchDictionaryController(settingsController);
- secondarySearchDictionaryController.prepare();
+ const permissionsToggleController = new PermissionsToggleController(settingsController);
+ permissionsToggleController.prepare();
- const translationTextReplacementsController = new TranslationTextReplacementsController(settingsController);
- translationTextReplacementsController.prepare();
+ const secondarySearchDictionaryController = new SecondarySearchDictionaryController(settingsController);
+ secondarySearchDictionaryController.prepare();
- const sentenceTerminationCharactersController = new SentenceTerminationCharactersController(settingsController);
- sentenceTerminationCharactersController.prepare();
+ const translationTextReplacementsController = new TranslationTextReplacementsController(settingsController);
+ translationTextReplacementsController.prepare();
- const keyboardShortcutController = new KeyboardShortcutController(settingsController);
- keyboardShortcutController.prepare();
+ const sentenceTerminationCharactersController = new SentenceTerminationCharactersController(settingsController);
+ sentenceTerminationCharactersController.prepare();
- const extensionKeyboardShortcutController = new ExtensionKeyboardShortcutController(settingsController);
- extensionKeyboardShortcutController.prepare();
+ const keyboardShortcutController = new KeyboardShortcutController(settingsController);
+ keyboardShortcutController.prepare();
- const popupWindowController = new PopupWindowController(application.api);
- popupWindowController.prepare();
+ const extensionKeyboardShortcutController = new ExtensionKeyboardShortcutController(settingsController);
+ extensionKeyboardShortcutController.prepare();
- const mecabController = new MecabController(application.api);
- mecabController.prepare();
+ const popupWindowController = new PopupWindowController(application.api);
+ popupWindowController.prepare();
- const collapsibleDictionaryController = new CollapsibleDictionaryController(settingsController);
- collapsibleDictionaryController.prepare();
+ const mecabController = new MecabController(application.api);
+ mecabController.prepare();
- const sortFrequencyDictionaryController = new SortFrequencyDictionaryController(settingsController);
- sortFrequencyDictionaryController.prepare();
+ const collapsibleDictionaryController = new CollapsibleDictionaryController(settingsController);
+ collapsibleDictionaryController.prepare();
- await Promise.all(preparePromises);
+ const sortFrequencyDictionaryController = new SortFrequencyDictionaryController(settingsController);
+ sortFrequencyDictionaryController.prepare();
- document.documentElement.dataset.loaded = 'true';
+ await Promise.all(preparePromises);
- const settingsDisplayController = new SettingsDisplayController(settingsController, modalController);
- settingsDisplayController.prepare();
- } catch (e) {
- log.error(e);
- }
-}
+ document.documentElement.dataset.loaded = 'true';
-await main();
+ const settingsDisplayController = new SettingsDisplayController(settingsController, modalController);
+ settingsDisplayController.prepare();
+});