From b8adffc4adfc631963657efd7a969e2b7a9f345a Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 29 Dec 2025 02:37:39 +0100 Subject: [PATCH] fix: Request notification permission on room join MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Request push notification permission automatically when joining a room, similar to how location permission is requested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/app/[slug]/page.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx index 1c761d6..7bd5653 100644 --- a/src/app/[slug]/page.tsx +++ b/src/app/[slug]/page.tsx @@ -148,15 +148,17 @@ export default function RoomPage() { roomSlug: slug, }); - // Auto-subscribe to push when location sharing starts + // Auto-subscribe to push when joining room (like location permission) + const hasRequestedPushRef = useRef(false); useEffect(() => { - if (isSharing && !isPushSubscribed && syncUrl) { - console.log('Auto-subscribing to push notifications for background pings'); + if (isConnected && !isPushSubscribed && !hasRequestedPushRef.current && syncUrl) { + hasRequestedPushRef.current = true; + console.log('Auto-requesting push notification permission'); subscribePush().catch((err) => { console.warn('Push subscription failed (user may have denied):', err.message); }); } - }, [isSharing, isPushSubscribed, subscribePush, syncUrl]); + }, [isConnected, isPushSubscribed, subscribePush, syncUrl]); // Restore last known location immediately when connected const hasRestoredLocationRef = useRef(false);