diff --git a/README.md b/README.md index 49ad7d8..98dce40 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Instructions to get the source URL for some calendar services: After configuration, run the `{[iCalendar: Sync]}` command to synchronize calendar events. The plug will cache the results for 6 hours by default (configurable via `cacheDuration` in config). +To bypass the cache and force an immediate sync, use the `{[iCalendar: Force Sync]}` command. + Events are indexed with the tag `ical-event` and can be queried using Lua Integrated Query (LIQ). ### Examples diff --git a/icalendar.plug.yaml b/icalendar.plug.yaml index b3f5a6a..4bd46f7 100644 --- a/icalendar.plug.yaml +++ b/icalendar.plug.yaml @@ -7,6 +7,11 @@ functions: command: name: "iCalendar: Sync" priority: -1 + forceSync: + path: ./icalendar.ts:forceSync + command: + name: "iCalendar: Force Sync" + priority: -1 showVersion: path: ./icalendar.ts:showVersion command: diff --git a/icalendar.ts b/icalendar.ts index 7baa066..f752dc6 100644 --- a/icalendar.ts +++ b/icalendar.ts @@ -208,6 +208,14 @@ async function getSources(): Promise { return validated; } +/** + * Forces a fresh sync by clearing cache and then syncing calendars + */ +export async function forceSync() { + await clientStore.del(CACHE_KEY); + console.log("[iCalendar] Cache cleared, forcing fresh sync"); + await editor.flashNotification("Forcing fresh calendar sync...", "info"); + await syncCalendars(); } /**