From 3dcf9d16710b0b378c1c87eaa8e136e440849713 Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Fri, 6 Mar 2026 17:41:47 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20isSharedEvent=20excluding=20calendar=20ow?= =?UTF-8?q?ners=20=E2=80=94=20lock=20banner=20never=20appeared=20for=20own?= =?UTF-8?q?ers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The selectedEventIsShared check used `permissionMap.get(...) !== 'owner'` which excluded calendar owners from all shared-event behavior (lock polling, lock acquisition, lock banner display). Replaced with a sharedCalendarIds set that includes both owned shared calendars (via cal.is_shared) and memberships. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/calendar/CalendarPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/calendar/CalendarPage.tsx b/frontend/src/components/calendar/CalendarPage.tsx index ba8899a..3f0543a 100644 --- a/frontend/src/components/calendar/CalendarPage.tsx +++ b/frontend/src/components/calendar/CalendarPage.tsx @@ -70,6 +70,14 @@ export default function CalendarPage() { return map; }, [calendars, sharedData]); + // Set of calendar IDs that are shared (owned or membership) + const sharedCalendarIds = useMemo(() => { + const ids = new Set(); + calendars.forEach((cal) => { if (cal.is_shared) ids.add(cal.id); }); + sharedData.forEach((m) => ids.add(m.calendar_id)); + return ids; + }, [calendars, sharedData]); + // Handle navigation state from dashboard useEffect(() => { const state = location.state as { date?: string; view?: string; eventId?: number } | null; @@ -158,7 +166,7 @@ export default function CalendarPage() { ); const selectedEventPermission = selectedEvent ? permissionMap.get(selectedEvent.calendar_id) ?? null : null; - const selectedEventIsShared = selectedEvent ? permissionMap.has(selectedEvent.calendar_id) && permissionMap.get(selectedEvent.calendar_id) !== 'owner' : false; + const selectedEventIsShared = selectedEvent ? sharedCalendarIds.has(selectedEvent.calendar_id) : false; // Close panel if shared calendar was removed while viewing useEffect(() => {