From ca9ecbb6e8d6a281bd409f754e392418163e0672 Mon Sep 17 00:00:00 2001 From: "Stephane Lacoin (aka nxmatic)" Date: Thu, 11 Jul 2024 16:14:16 +0200 Subject: [PATCH] [loading] enforce javascript execution starting --- src/popup/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/popup/index.js b/src/popup/index.js index 10f0b53..137b23f 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -226,6 +226,9 @@ Please open the JavaScript console of the nuxeo w $('#reset').css('top', 5); }; + // reset jQuery event handlers + $('body').find('*').addBack().off(); + worker.connectLocator .asRegistration() .then((input) => { @@ -234,10 +237,6 @@ Please open the JavaScript console of the nuxeo w const connectCredentials = credentials; return { connectUrl, connectCredentials, ...input }; }) - // wait for the document to be ready - .then((input) => new Promise((resolve) => { - $(document).ready(() => resolve(input)); - })) // remove the studio package name input if the feature flag is not set .then((input) => worker.developmentMode .isFeatureFlagSet('studio-package-name') @@ -251,8 +250,6 @@ Please open the JavaScript console of the nuxeo w // eslint-disable-next-line no-unused-vars .then(({ connectUrl, connectCredentials, cookiesGranted }) => { const pendingPromises = []; - // reset jQuery event handlers - $('body').find('*').addBack().off(); $('#connect-url-input').val(connectUrl); // Grant cookies permissions to connect if needed @@ -991,6 +988,8 @@ Please open the JavaScript console of the nuxeo w .catch((cause) => stopLoading(cause)); } -new ServiceWorkerBridge() - .bootstrap({ name: 'reloadPopup', entrypoint: loadPage }) - .catch((error) => console.error(error)); +document.addEventListener('DOMContentLoaded', () => { + const worker = new ServiceWorkerBridge(); + worker.bootstrap({ name: 'popup', entrypoint: loadPage }) + .catch((error) => console.error(error)); +});