From fbde1a20306f2a6f4d270aa94f673b3b5c96a615 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:21:09 +0530 Subject: [PATCH] fix: image not loading on mobile after lock/unlock (#2631) image not loading on mobile after lock/unlock --- src/index.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 0019a224..71e723ab 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,10 +27,24 @@ if ('serviceWorker' in navigator) { ? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js` : `/dev-sw.js?dev-sw`; - navigator.serviceWorker.register(swUrl).then(() => { + const sendSessionToSW = () => { const session = getFallbackSession(); pushSessionToSW(session?.baseUrl, session?.accessToken); + }; + + navigator.serviceWorker.register(swUrl).then(sendSessionToSW); + navigator.serviceWorker.ready.then(sendSessionToSW); + window.addEventListener('load', sendSessionToSW); + + // When returning from background + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible') { + sendSessionToSW(); + } }); + + // When restored from bfcache (important on iOS) + window.addEventListener('pageshow', sendSessionToSW); } const mountApp = () => {