forked from GitHubMirrors/silverbullet-icalendar
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:
@@ -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).
|
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).
|
Events are indexed with the tag `ical-event` and can be queried using Lua Integrated Query (LIQ).
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ functions:
|
|||||||
command:
|
command:
|
||||||
name: "iCalendar: Sync"
|
name: "iCalendar: Sync"
|
||||||
priority: -1
|
priority: -1
|
||||||
|
forceSync:
|
||||||
|
path: ./icalendar.ts:forceSync
|
||||||
|
command:
|
||||||
|
name: "iCalendar: Force Sync"
|
||||||
|
priority: -1
|
||||||
showVersion:
|
showVersion:
|
||||||
path: ./icalendar.ts:showVersion
|
path: ./icalendar.ts:showVersion
|
||||||
command:
|
command:
|
||||||
|
|||||||
@@ -208,6 +208,14 @@ async function getSources(): Promise<Source[]> {
|
|||||||
return validated;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user