From 10a64f892781bf285b0be196a79409756ae00ec2 Mon Sep 17 00:00:00 2001 From: "Marek S. Lukasiewicz" Date: Sat, 4 Jan 2025 19:22:43 +0100 Subject: [PATCH] Fix querying with filters --- caldav.ts | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/caldav.ts b/caldav.ts index 192ae26..0464226 100644 --- a/caldav.ts +++ b/caldav.ts @@ -28,7 +28,7 @@ export async function queryEvents( return []; } - let events: Event[] = calendarParsed.events.map((ics) => { + const events: Event[] = calendarParsed.events.map((ics) => { return { summary: ics.summary, 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 - events = applyQuery(query, events); - return events; + return applyQuery(query, events, {}, {}); } // 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.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; -}