Fix event lock system: banner persistence, stale isEditing guard, and Edit button gating
- Remove isEditing guard from viewLockQuery effect so lock banner shows for user B even after user A transitions into edit mode (fixes banner disappearing) - Disable Edit button proactively when lockInfo.locked is already known from polling, preventing the user from even attempting acquireLock when a lock is active - Fix acquire callback dep array in useEventLock (missing acquireMutation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c55af91c60
commit
e62503424c
@ -276,16 +276,15 @@ export default function EventDetailPanel({
|
||||
refetchInterval: 5_000,
|
||||
});
|
||||
|
||||
// Show/hide lock banner proactively in view mode
|
||||
// Show/hide lock banner proactively in view mode (poll data always authoritative)
|
||||
useEffect(() => {
|
||||
if (viewLockQuery.data && !isEditing && !isCreating) {
|
||||
if (!viewLockQuery.data) return;
|
||||
if (viewLockQuery.data.locked) {
|
||||
setLockInfo(viewLockQuery.data);
|
||||
} else {
|
||||
setLockInfo(null);
|
||||
}
|
||||
}
|
||||
}, [viewLockQuery.data, isEditing, isCreating]);
|
||||
}, [viewLockQuery.data]);
|
||||
|
||||
const isRecurring = !!(event?.is_recurring || event?.parent_event_id);
|
||||
|
||||
@ -581,8 +580,8 @@ export default function EventDetailPanel({
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={handleEditStart}
|
||||
disabled={isAcquiringLock}
|
||||
title="Edit event"
|
||||
disabled={isAcquiringLock || !!(lockInfo && lockInfo.locked)}
|
||||
title={lockInfo && lockInfo.locked ? `Locked by ${lockInfo.locked_by_name || 'another user'}` : 'Edit event'}
|
||||
>
|
||||
{isAcquiringLock ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <Pencil className="h-3.5 w-3.5" />}
|
||||
</Button>
|
||||
|
||||
@ -34,7 +34,7 @@ export function useEventLock(eventId: number | null) {
|
||||
if (!eventId) return null;
|
||||
const data = await acquireMutation.mutateAsync(eventId);
|
||||
return data;
|
||||
}, [eventId]);
|
||||
}, [eventId, acquireMutation]);
|
||||
|
||||
const release = useCallback(async () => {
|
||||
const id = activeEventIdRef.current;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user