From 527ce2d97b1227826e9fe40c3702bb43d257f927 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:02:22 +0530 Subject: [PATCH] refactor(announcement-spotlight): simplify dismissal logic and update button style --- .../announcements/AnnouncementSpotlight.tsx | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/surfsense_web/components/announcements/AnnouncementSpotlight.tsx b/surfsense_web/components/announcements/AnnouncementSpotlight.tsx index 794a3c1cf..2eac913d8 100644 --- a/surfsense_web/components/announcements/AnnouncementSpotlight.tsx +++ b/surfsense_web/components/announcements/AnnouncementSpotlight.tsx @@ -20,14 +20,10 @@ import { useAnnouncements } from "@/hooks/use-announcements"; * Behaviour: * - On load, the first active, audience-matched, unread spotlight announcement * is shown automatically. - * - The user must explicitly acknowledge it ("Got it" or the CTA link), which - * marks it as read so it never shows again. - * - Closing via the X / Escape / outside-click only hides it for the current - * session; it reappears on the next load until the user marks it as seen. + * - Any dismissal marks it as read so it never shows again. */ export function AnnouncementSpotlight() { const { announcements, markRead } = useAnnouncements(); - const [sessionDismissed, setSessionDismissed] = useState>(() => new Set()); const [ready, setReady] = useState(false); // Short delay so the spotlight doesn't flash during initial hydration/layout. @@ -37,11 +33,8 @@ export function AnnouncementSpotlight() { }, []); const current = useMemo( - () => - announcements.find( - (a) => a.spotlight && a.isImportant && !a.isRead && !sessionDismissed.has(a.id) - ) ?? null, - [announcements, sessionDismissed] + () => announcements.find((a) => a.spotlight && a.isImportant && !a.isRead) ?? null, + [announcements] ); if (!current) return null; @@ -51,13 +44,7 @@ export function AnnouncementSpotlight() { }; const handleOpenChange = (next: boolean) => { - if (!next) { - setSessionDismissed((prev) => { - const updated = new Set(prev); - updated.add(current.id); - return updated; - }); - } + if (!next) markRead(current.id); }; return ( @@ -82,7 +69,7 @@ export function AnnouncementSpotlight() { {current.link && ( -