forked from GitHubMirrors/silverbullet-icalendar
Make configuration more robust for single sources
Some checks failed
Build SilverBullet Plug / build (push) Failing after 9s
Some checks failed
Build SilverBullet Plug / build (push) Failing after 9s
This commit is contained in:
12
icalendar.ts
12
icalendar.ts
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user