diff --git a/components/pwa-install-prompt.tsx b/components/pwa-install-prompt.tsx index 727d69c8..c5ac68c9 100644 --- a/components/pwa-install-prompt.tsx +++ b/components/pwa-install-prompt.tsx @@ -8,12 +8,16 @@ interface BeforeInstallPromptEvent extends Event { userChoice: Promise<{ outcome: "accepted" | "dismissed" }>; } +const DISMISSED_KEY = "pwa-install-dismissed"; + export function PWAInstallPrompt() { const [deferredPrompt, setDeferredPrompt] = useState(null); const [showPrompt, setShowPrompt] = useState(false); useEffect(() => { + if (localStorage.getItem(DISMISSED_KEY)) return; + const handler = (e: Event) => { e.preventDefault(); setDeferredPrompt(e as BeforeInstallPromptEvent); @@ -43,6 +47,11 @@ export function PWAInstallPrompt() { setShowPrompt(false); }; + const handleDismissForever = () => { + localStorage.setItem(DISMISSED_KEY, "1"); + setShowPrompt(false); + }; + if (!showPrompt || !deferredPrompt) { return null; } @@ -69,18 +78,26 @@ export function PWAInstallPrompt() { -
+
+
+ + +
-