diff --git a/client/src/components/push-prompt-banner.tsx b/client/src/components/push-prompt-banner.tsx index 621c59a..1abbd75 100644 --- a/client/src/components/push-prompt-banner.tsx +++ b/client/src/components/push-prompt-banner.tsx @@ -5,6 +5,7 @@ import { useToast } from "@/hooks/use-toast"; import { isPushSupported, getExistingSubscription, subscribeToPush } from "@/lib/push-utils"; const DISMISS_KEY = "folx-push-prompt-dismissed"; +const DISMISS_DAYS = 7; export default function PushPromptBanner() { const [visible, setVisible] = useState(false); @@ -12,9 +13,14 @@ export default function PushPromptBanner() { useEffect(() => { if (!isPushSupported()) return; - if (localStorage.getItem(DISMISS_KEY)) return; if (Notification.permission === "denied") return; + const dismissedAt = localStorage.getItem(DISMISS_KEY); + if (dismissedAt) { + const elapsed = Date.now() - parseInt(dismissedAt, 10); + if (elapsed < DISMISS_DAYS * 24 * 60 * 60 * 1000) return; + } + const timer = setTimeout(async () => { const sub = await getExistingSubscription(); if (!sub) setVisible(true); @@ -25,7 +31,7 @@ export default function PushPromptBanner() { const dismiss = () => { setVisible(false); - localStorage.setItem(DISMISS_KEY, "1"); + localStorage.setItem(DISMISS_KEY, Date.now().toString()); }; const accept = async () => {