Make configuration more robust for single sources
Some checks failed
Build SilverBullet Plug / build (push) Failing after 9s

This commit is contained in:
2026-02-15 17:39:32 -08:00
parent 6641f03519
commit bb1b9a93ad

View File

@@ -118,19 +118,21 @@ function convertDatesToStrings<T>(obj: T): DateToString<T> {
* Retrieves and validates configured calendar sources
*/
async function getSources(): Promise<Source[]> {
// Using system.getSpaceConfig as config.get is being phased out in syscalls
const plugConfig = await config.get<PlugConfig>("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;