mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-08-03 06:16:21 +00:00
update AppImage 1.2.3
This commit is contained in:
Binary file not shown.
@@ -1 +1 @@
|
|||||||
740deb4de0a91d7ebbc8d7296c5f13500d6892480b207536c22ad2afc2de009c ProxMenux-1.2.3.AppImage
|
cd07523bc6d5127029d352fcd9488bb90b37c42809d5061cb22aa8a442f036bb ProxMenux-1.2.3.AppImage
|
||||||
|
|||||||
@@ -12,27 +12,63 @@ import { useEffect } from "react"
|
|||||||
// PWA-installability check from no-to-yes.
|
// PWA-installability check from no-to-yes.
|
||||||
//
|
//
|
||||||
// Mounted from app/layout.tsx so it runs on every route.
|
// Mounted from app/layout.tsx so it runs on every route.
|
||||||
|
//
|
||||||
|
// On every `visibilitychange` back to visible we call
|
||||||
|
// `registration.update()`. Mobile browsers (Brave / Firefox
|
||||||
|
// Android/iOS) are aggressive about deferring the SW's
|
||||||
|
// scheduled 24h `sw.js` re-check to save battery, which
|
||||||
|
// stranded users on the pre-v2 SW after the Cache Storage
|
||||||
|
// fix shipped — they saw the dashboard freeze until they
|
||||||
|
// force-stopped the browser. Forcing an `update()` on every
|
||||||
|
// return-to-foreground brings the SW check inline with
|
||||||
|
// user attention so future SW_VERSION bumps propagate at
|
||||||
|
// the first regreso a la pestaña instead of hours later.
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
export function PwaRegister() {
|
export function PwaRegister() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window === "undefined") return
|
if (typeof window === "undefined") return
|
||||||
if (!("serviceWorker" in navigator)) return
|
if (!("serviceWorker" in navigator)) return
|
||||||
// Wait for the load event to avoid competing with the
|
|
||||||
// initial render — the SW registration is not on the
|
let registration: ServiceWorkerRegistration | null = null
|
||||||
// critical render path.
|
|
||||||
const register = () => {
|
const register = () => {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register("/sw.js", { scope: "/" })
|
.register("/sw.js", { scope: "/" })
|
||||||
|
.then((reg) => {
|
||||||
|
registration = reg
|
||||||
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// Surface the failure only in DevTools — silent in prod.
|
// Surface the failure only in DevTools — silent in prod.
|
||||||
console.warn("[pwa] service worker registration failed:", err)
|
console.warn("[pwa] service worker registration failed:", err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onVisible = () => {
|
||||||
|
if (document.visibilityState !== "visible") return
|
||||||
|
// Prefer the captured registration from the initial register()
|
||||||
|
// call; fall back to `getRegistration()` in case that promise
|
||||||
|
// hadn't resolved yet on the first visibility change.
|
||||||
|
if (registration) {
|
||||||
|
registration.update().catch(() => {})
|
||||||
|
} else {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.getRegistration()
|
||||||
|
.then((reg) => reg?.update().catch(() => {}))
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (document.readyState === "complete") {
|
if (document.readyState === "complete") {
|
||||||
register()
|
register()
|
||||||
} else {
|
} else {
|
||||||
window.addEventListener("load", register, { once: true })
|
window.addEventListener("load", register, { once: true })
|
||||||
return () => window.removeEventListener("load", register)
|
}
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", onVisible)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("load", register)
|
||||||
|
document.removeEventListener("visibilitychange", onVisible)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in New Issue
Block a user