Skip to content

Commit 5e90bcd

Browse files
fix: CalDAV delete and sync issues
- EventCard context menu now deletes via CalDAV (not just locally) - Command Palette sync now works (passes syncAll function) - Sync properly detects and deletes local events removed from server
1 parent e135409 commit 5e90bcd

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/features/calendar/components/EventCard.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { format, parseISO } from 'date-fns'
44
import { useDraggable } from '@dnd-kit/core'
55
import { useCalendarStore } from '@/store/calendarStore'
66
import { useSettingsStore } from '@/store/settingsStore'
7+
import { useCalDAV } from '@/features/caldav/hooks/useCalDAV'
78
import { ContextMenu } from '@/components/common/ContextMenu'
89
import type { CalendarEvent } from '@/types'
910
import { DEFAULT_CALENDAR_COLOR } from '@/config'
@@ -32,6 +33,7 @@ export function EventCard({
3233
const deleteEvent = useCalendarStore((state) => state.deleteEvent)
3334
const duplicateEvent = useCalendarStore((state) => state.duplicateEvent)
3435
const timeFormat = useSettingsStore((state) => state.timeFormat)
36+
const { deleteEvent: deleteCalDAVEvent } = useCalDAV()
3537

3638
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null)
3739

@@ -248,7 +250,14 @@ export function EventCard({
248250
},
249251
{
250252
label: 'Delete',
251-
onClick: () => deleteEvent(event.id),
253+
onClick: async () => {
254+
deleteEvent(event.id)
255+
try {
256+
await deleteCalDAVEvent(event.calendarId, event.id)
257+
} catch {
258+
// error handled by useCalDAV
259+
}
260+
},
252261
icon: <DeleteIcon />,
253262
danger: true,
254263
},

src/features/commandPalette/hooks/useCommandPalette.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useMemo, useCallback, useState, useEffect } from 'react'
22
import { useNavigate } from 'react-router-dom'
33
import { useCalendarStore } from '@/store/calendarStore'
44
import { useSettingsStore } from '@/store/settingsStore'
5+
import { useCalDAV } from '@/features/caldav/hooks/useCalDAV'
56
import { createCommandRegistry, type Command } from '../commands'
67
import { parseNaturalLanguage, type NLPParseResult } from '@/features/nlp'
78
import type {
@@ -35,6 +36,9 @@ export function useCommandPalette({ isOpen }: UseCommandPaletteProps) {
3536

3637
const themeMode = useSettingsStore((state) => state.themeMode)
3738
const updateSettings = useSettingsStore((state) => state.updateSettings)
39+
const accounts = useCalendarStore((state) => state.calendars)
40+
41+
const { syncAll } = useCalDAV()
3842

3943
const commands = useMemo(() => {
4044
return createCommandRegistry({
@@ -44,8 +48,9 @@ export function useCommandPalette({ isOpen }: UseCommandPaletteProps) {
4448
openModal,
4549
themeMode,
4650
updateSettings,
51+
triggerSync: syncAll,
4752
})
48-
}, [navigate, setCurrentView, setCurrentDate, openModal, themeMode, updateSettings])
53+
}, [navigate, setCurrentView, setCurrentDate, openModal, themeMode, updateSettings, syncAll])
4954

5055
const parseInput = useCallback((input: string): ParsedInput => {
5156
const trimmed = input.trim().toLowerCase()

0 commit comments

Comments
 (0)