diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-04-10 23:55:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-10 23:55:11 -0400 |
commit | 20d60a2ba79c065586805806ea703a8057839f75 (patch) | |
tree | 3043090e118e03a8e276d2a7f1557e525ac23239 /ext/js/pages/settings/settings-main.js | |
parent | b23c4bff4bf319ea79eea0d025e21eb19e6dcd68 (diff) |
Initial safari compatibility (#1609)
* Update environment info to return the 'safari' browser
* Fix popup display on Safari
* Update environment assignment
* Add data-loading-stalled property when loading takes longer than expected
* Add notification when loading has stalled
* Allow getDictionaryInfo invocation on non-privileged contexts
* Update _validatePrivilegedMessageSender
* Don't listen to 'voiceschanged' event unless addEventListener is present
Also expose an event
Diffstat (limited to 'ext/js/pages/settings/settings-main.js')
-rw-r--r-- | ext/js/pages/settings/settings-main.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js index 2560685c..6f3e2a58 100644 --- a/ext/js/pages/settings/settings-main.js +++ b/ext/js/pages/settings/settings-main.js @@ -24,6 +24,7 @@ * DictionaryController * DictionaryImportController * DocumentFocusController + * Environment * ExtensionKeyboardShortcutController * GenericSettingController * KeyboardShortcutController @@ -47,11 +48,16 @@ */ async function setupEnvironmentInfo() { + const {dataset} = document.documentElement; const {manifest_version: manifestVersion} = chrome.runtime.getManifest(); - const {browser, platform} = await yomichan.api.getEnvironmentInfo(); - document.documentElement.dataset.browser = browser; - document.documentElement.dataset.os = platform.os; - document.documentElement.dataset.manifestVersion = `${manifestVersion}`; + dataset.manifestVersion = `${manifestVersion}`; + + const environment = new Environment(); + await environment.prepare(); + const {browser, platform} = environment.getInfo(); + + dataset.browser = browser; + dataset.os = platform.os; } async function setupGenericSettingsController(genericSettingController) { @@ -67,9 +73,20 @@ async function setupGenericSettingsController(genericSettingController) { const statusFooter = new StatusFooter(document.querySelector('.status-footer-container')); statusFooter.prepare(); + setupEnvironmentInfo(); + + let prepareTimer = setTimeout(() => { + prepareTimer = null; + document.documentElement.dataset.loadingStalled = 'true'; + }, 1000); + await yomichan.prepare(); - setupEnvironmentInfo(); + if (prepareTimer !== null) { + clearTimeout(prepareTimer); + prepareTimer = null; + } + delete document.documentElement.dataset.loadingStalled; const optionsFull = await yomichan.api.optionsGetFull(); |