forked from GitHubMirrors/silverbullet-icalendar
Fix: Final clean build v0.3.14 with verified mapping and name
All checks were successful
Build SilverBullet Plug / build (push) Successful in 19s
All checks were successful
Build SilverBullet Plug / build (push) Successful in 19s
This commit is contained in:
21
icalendar.ts
21
icalendar.ts
@@ -1,7 +1,7 @@
|
||||
import { clientStore, config, datastore, editor, index } from "@silverbulletmd/silverbullet/syscalls";
|
||||
import { convertIcsCalendar } from "https://esm.sh/ts-ics@2.4.0";
|
||||
|
||||
const VERSION = "0.3.13";
|
||||
const VERSION = "0.3.14";
|
||||
const CACHE_KEY = "icalendar:lastSync";
|
||||
|
||||
console.log(`[iCalendar] Plug script executing at top level (Version ${VERSION})`);
|
||||
@@ -73,19 +73,24 @@ export async function syncCalendars() {
|
||||
console.log(`[iCalendar] syncCalendars command triggered`);
|
||||
try {
|
||||
const { sources, tzShift } = await getSources();
|
||||
console.log(`[iCalendar] Found ${sources.length} sources, tzShift: ${tzShift}`);
|
||||
if (sources.length === 0) return;
|
||||
if (sources.length === 0) {
|
||||
await editor.flashNotification("No calendar sources configured", "warn");
|
||||
return;
|
||||
}
|
||||
await editor.flashNotification("Syncing calendars...", "info");
|
||||
const allEvents: any[] = [];
|
||||
for (const source of sources) {
|
||||
const events = await fetchAndParseCalendar(source, tzShift);
|
||||
allEvents.push(...events);
|
||||
try {
|
||||
const events = await fetchAndParseCalendar(source, tzShift);
|
||||
allEvents.push(...events);
|
||||
} catch (err) {
|
||||
console.error(`Failed to sync ${source.name}:`, err);
|
||||
}
|
||||
}
|
||||
await index.indexObjects("$icalendar", allEvents);
|
||||
console.log(`[iCalendar] Successfully indexed ${allEvents.length} events`);
|
||||
await editor.flashNotification(`Synced ${allEvents.length} events`, "info");
|
||||
} catch (err) {
|
||||
console.error("[iCalendar] Sync failed:", err);
|
||||
console.error("Sync failed:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,4 +117,4 @@ export async function clearCache() {
|
||||
export async function showVersion() {
|
||||
console.log(`[iCalendar] showVersion command triggered`);
|
||||
await editor.flashNotification(`iCalendar Plug ${VERSION}`, "info");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user