Fix querying with filters

This commit is contained in:
Marek S. Lukasiewicz
2025-01-04 19:22:43 +01:00
parent c028032787
commit 10a64f8927

View File

@@ -28,7 +28,7 @@ export async function queryEvents(
return []; return [];
} }
let events: Event[] = calendarParsed.events.map((ics) => { const events: Event[] = calendarParsed.events.map((ics) => {
return { return {
summary: ics.summary, summary: ics.summary,
description: ics.description, description: ics.description,
@@ -43,9 +43,7 @@ export async function queryEvents(
}; };
}); });
// FIXME: Fails whenever any filters are applied, but same code works for github plug return applyQuery(query, events, {}, {});
events = applyQuery(query, events);
return events;
} }
// Copied from @silverbulletmd/silverbullet/lib/dates.ts which is not exported in the package // Copied from @silverbulletmd/silverbullet/lib/dates.ts which is not exported in the package
@@ -58,19 +56,3 @@ export function localDateString(d: Date): string {
":" + String(d.getSeconds()).padStart(2, "0") + ":" + String(d.getSeconds()).padStart(2, "0") +
"." + String(d.getMilliseconds()).padStart(3, "0"); "." + String(d.getMilliseconds()).padStart(3, "0");
} }
// didn't help
function flattenObject(obj: any, prefix = ""): any {
let result: any = {};
for (let [key, value] of Object.entries(obj)) {
if (prefix) {
key = prefix + "_" + key;
}
if (value && typeof value === "object") {
result = { ...result, ...flattenObject(value, key) };
} else {
result[key] = value;
}
}
return result;
}