Fix isSharedEvent excluding calendar owners — lock banner never appeared for owners
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 <noreply@anthropic.com>
This commit is contained in:
parent
e62503424c
commit
3dcf9d1671
@ -70,6 +70,14 @@ export default function CalendarPage() {
|
|||||||
return map;
|
return map;
|
||||||
}, [calendars, sharedData]);
|
}, [calendars, sharedData]);
|
||||||
|
|
||||||
|
// Set of calendar IDs that are shared (owned or membership)
|
||||||
|
const sharedCalendarIds = useMemo(() => {
|
||||||
|
const ids = new Set<number>();
|
||||||
|
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
|
// Handle navigation state from dashboard
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const state = location.state as { date?: string; view?: string; eventId?: number } | null;
|
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 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
|
// Close panel if shared calendar was removed while viewing
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user