Add force sync command

Add 'iCalendar: Force Sync' command to bypass cache and
immediately synchronize calendar events. Useful when you
need fresh data before the cache expires.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Alexandre Nicolaie <xunleii@users.noreply.github.com>
This commit is contained in:
Alexandre Nicolaie
2025-10-18 10:30:45 +02:00
parent d3e4fc021b
commit 38dd97c25c
3 changed files with 15 additions and 0 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -208,6 +208,14 @@ async function getSources(): Promise<Source[]> {
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();
}
/**