Skip to content

Commit

Permalink
(feat) O3-3010: Disable triggering offline mode when offline disabled (
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Mar 28, 2024
1 parent bdf68fe commit c94ac5b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/shell/esm-app-shell/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ function connectivityChanged() {
* Runs the shell by importing the translations and starting single SPA.
*/
function runShell() {
window.addEventListener('offline', connectivityChanged);
window.addEventListener('online', connectivityChanged);
return setupI18n()
.catch((err) => console.error(`Failed to initialize translations`, err))
.then(() => start());
Expand Down Expand Up @@ -378,6 +376,11 @@ async function precacheImportMap() {
});
}

function registerOfflineHandlers() {
window.addEventListener('offline', connectivityChanged);
window.addEventListener('online', connectivityChanged);
}

function setupOfflineCssClasses() {
subscribeConnectivity(({ online }) => {
const body = document.querySelector('body')!;
Expand Down Expand Up @@ -410,7 +413,8 @@ export function run(configUrls: Array<string>, offline: boolean) {

return setupApps()
.then(finishRegisteringAllApps)
.then(setupOfflineCssClasses)
.then(offline ? setupOfflineCssClasses : undefined)
.then(offline ? registerOfflineHandlers : undefined)
.then(provideConfigs)
.then(runShell)
.catch(handleInitFailure)
Expand Down

0 comments on commit c94ac5b

Please sign in to comment.