fix: image not loading on mobile after lock/unlock (#2631)

image not loading on mobile after lock/unlock
This commit is contained in:
Ajay Bura 2026-02-16 14:21:09 +05:30 committed by GitHub
parent 4ba7b9162d
commit fbde1a2030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,10 +27,24 @@ if ('serviceWorker' in navigator) {
? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js` ? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
: `/dev-sw.js?dev-sw`; : `/dev-sw.js?dev-sw`;
navigator.serviceWorker.register(swUrl).then(() => { const sendSessionToSW = () => {
const session = getFallbackSession(); const session = getFallbackSession();
pushSessionToSW(session?.baseUrl, session?.accessToken); 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 = () => { const mountApp = () => {