Add PWA update prompt instead of silent stale caching

Previously the service worker used registerType: 'autoUpdate' with
the default injected register script - a new deploy would install
and activate a new SW in the background, but an already-open tab
kept running the old JS/CSS from memory with no indication a newer
version existed, short of a manual hard reload (or clearing SW/
caches by hand, which we had to do repeatedly while verifying
deploys this session).

Switch to registerType: 'prompt' and register the SW ourselves via
virtual:pwa-register/react (useRegisterSW), showing a small "new
version available" toast with a reload button when an update is
waiting. Also poll registration.update() hourly so long-lived tabs
notice updates without needing a fresh navigation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-09-10 09:13:15 +02:00
1 parent dc35526727
commit 5b5f4caf79
5 files changed
+88 -1

No files matched your search

+6
View File
@@ -48,6 +48,9 @@ const translations: Record<Lang, Record<string, string>> = {
"menu.extras.feedback": "Feedback geben",
"feedback.fab.nudge": "Was denkst du über WebSpeak3? Feedback ist willkommen!",
"pwa.updateAvailable": "Neue Version verfügbar",
"pwa.reload": "Neu laden",
"feedback.dialog.title": "Feedback",
"feedback.dialog.intro": "Melde einen Fehler oder teile eine Idee zur Weiterentwicklung von WebSpeak3 mit.",
"feedback.dialog.category": "Kategorie",
@@ -634,6 +637,9 @@ const translations: Record<Lang, Record<string, string>> = {
"menu.extras.feedback": "Send Feedback",
"feedback.fab.nudge": "What do you think of WebSpeak3? Feedback welcome!",
"pwa.updateAvailable": "New version available",
"pwa.reload": "Reload",
"feedback.dialog.title": "Feedback",
"feedback.dialog.intro": "Report a bug or share an idea to help improve WebSpeak3.",
"feedback.dialog.category": "Category",