From 478dbf21024adfe7eed97f0f637a2d3e59429eb3 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 5 Mar 2022 04:44:03 +0100 Subject: [PATCH] feat(data): perform actual filtering on the calendar (very slow atm due to some reactiveness magic behavior) --- src/App.svelte | 18 +++++++++++++++--- src/calendar.js | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 0b21292..fa67410 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -37,18 +37,30 @@ let selectedCalendars; - onMount(async () => { + async function reloadEvents(selectedCalendars, options) { const evts = await refreshEvents(selectedCalendars); - options.events = evts.flat(); + return evts.flat(); + } + + + onMount(async () => { + options.events = await reloadEvents(selectedCalendars, options); options = { ...options }; }); + + $: { + reloadEvents(selectedCalendars, options).then(events => { + options.events = events; + options = { ...options }; + }); + }

Calendrier de la vie étudiante à l'ENS

- +
diff --git a/src/calendar.js b/src/calendar.js index 7e17974..4a6570a 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -117,7 +117,7 @@ export function mkEvent(title, start, duration, ...rest) { export function refreshEvents(selectedCalendars) { return Promise.all( calendarIds - .filter(id => selectedCalendars ? selectedCalendars.includes(id) : true) + .filter(id => selectedCalendars ? selectedCalendars.includes(calendars[id].name) : true) .map(id => mkEventsFromCalendar(id, calendars[id])) ); }