fix: image not loading on mobile after lock/unlock (#2631)
image not loading on mobile after lock/unlock
This commit is contained in:
parent
4ba7b9162d
commit
fbde1a2030
1 changed files with 15 additions and 1 deletions
|
|
@ -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 = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue