mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-08-03 22:36:44 +00:00
Update AppImage 1.2.3
This commit is contained in:
Binary file not shown.
@@ -1 +1 @@
|
|||||||
7b5dd3ff6fe70a190caf00d1ce5198dfe1917af53d01ab4fd1a3908f3204c0ff ProxMenux-1.2.3.AppImage
|
b6c602eb3bc056e8d8baddab98cf87d3897b8ff974395c2a32e28cf89e0238be ProxMenux-1.2.3.AppImage
|
||||||
|
|||||||
@@ -12,63 +12,27 @@ 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
|
||||||
let registration: ServiceWorkerRegistration | null = null
|
// initial render — the SW registration is not on the
|
||||||
|
// 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
|
||||||
|
|||||||
+10
-19
@@ -8,14 +8,12 @@
|
|||||||
// so we do NOT cache pages or API responses — caching them
|
// so we do NOT cache pages or API responses — caching them
|
||||||
// would only cause stale-data bugs after an AppImage update.
|
// would only cause stale-data bugs after an AppImage update.
|
||||||
//
|
//
|
||||||
// The install / activate handlers wipe every cache in Cache
|
// The install / activate handlers clean up old SW caches from
|
||||||
// Storage (no allow-list) so stale entries from any previous
|
// previous Monitor versions so a beta-to-stable upgrade never
|
||||||
// Monitor version — including ones that shared this SW's
|
// strands the browser on a cached old shell.
|
||||||
// version name — cannot survive an upgrade and haunt the
|
|
||||||
// dashboard as frozen `/api/*` responses.
|
|
||||||
// ==========================================================
|
// ==========================================================
|
||||||
|
|
||||||
const SW_VERSION = 'proxmenux-monitor-v2';
|
const SW_VERSION = 'proxmenux-monitor-v1';
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
// Take over as soon as installed; no skipWaiting handshake.
|
// Take over as soon as installed; no skipWaiting handshake.
|
||||||
@@ -24,19 +22,12 @@ self.addEventListener('install', (event) => {
|
|||||||
|
|
||||||
self.addEventListener('activate', (event) => {
|
self.addEventListener('activate', (event) => {
|
||||||
event.waitUntil((async () => {
|
event.waitUntil((async () => {
|
||||||
// Scorched earth: wipe EVERY cache, regardless of name. This
|
// Wipe any cache name that isn't ours — survives renames /
|
||||||
// SW never writes to Cache Storage, so nothing here should
|
// version bumps without piling up stale entries.
|
||||||
// ever be authoritative. The previous version kept caches
|
const names = await caches.keys();
|
||||||
// that matched SW_VERSION exactly, which stranded old cached
|
await Promise.all(
|
||||||
// /api/* responses across upgrades and manifested as a
|
names.filter((n) => n !== SW_VERSION).map((n) => caches.delete(n))
|
||||||
// dashboard that never refreshed until the user manually
|
);
|
||||||
// cleared Cache Storage from DevTools.
|
|
||||||
try {
|
|
||||||
const names = await caches.keys();
|
|
||||||
await Promise.all(names.map((n) => caches.delete(n)));
|
|
||||||
} catch (_) {
|
|
||||||
// caches API unavailable — nothing to clean.
|
|
||||||
}
|
|
||||||
await self.clients.claim();
|
await self.clients.claim();
|
||||||
})());
|
})());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user