diff --git a/icalendar.ts b/icalendar.ts index fbc3e41..8d7cc2b 100644 --- a/icalendar.ts +++ b/icalendar.ts @@ -118,19 +118,21 @@ function convertDatesToStrings(obj: T): DateToString { * Retrieves and validates configured calendar sources */ async function getSources(): Promise { + // Using system.getSpaceConfig as config.get is being phased out in syscalls const plugConfig = await config.get("icalendar", { sources: [] }); - if (!plugConfig.sources || !Array.isArray(plugConfig.sources)) { - console.error("[iCalendar] Invalid configuration:", { plugConfig }); + if (!plugConfig.sources) { return []; } - if (plugConfig.sources.length === 0) { - return []; + // Handle case where user provides a single object instead of an array + let sources = plugConfig.sources; + if (!Array.isArray(sources)) { + sources = [sources as unknown as Source]; } const validated: Source[] = []; - for (const src of plugConfig.sources) { + for (const src of sources) { if (typeof src.url !== "string") { console.error("[iCalendar] Invalid source (missing url):", src); continue;