feat(data): perform actual filtering on the calendar (very slow atm due to some reactiveness magic behavior)

This commit is contained in:
Raito Bezarius 2022-03-05 04:44:03 +01:00
parent 3fee527be1
commit 478dbf2102
2 changed files with 16 additions and 4 deletions

View file

@ -37,18 +37,30 @@
let selectedCalendars; let selectedCalendars;
onMount(async () => { async function reloadEvents(selectedCalendars, options) {
const evts = await refreshEvents(selectedCalendars); const evts = await refreshEvents(selectedCalendars);
options.events = evts.flat(); return evts.flat();
}
onMount(async () => {
options.events = await reloadEvents(selectedCalendars, options);
options = { ...options }; options = { ...options };
}); });
$: {
reloadEvents(selectedCalendars, options).then(events => {
options.events = events;
options = { ...options };
});
}
</script> </script>
<div class="app-container"> <div class="app-container">
<h1 class="title">Calendrier de la vie étudiante à l'ENS</h1> <h1 class="title">Calendrier de la vie étudiante à l'ENS</h1>
<div style="height: 100%; display: flex;"> <div style="height: 100%; display: flex;">
<Modal show={$modal}> <Modal show={$modal}>
<FilterBar {calendarTree} {selectedCalendars} /> <FilterBar {calendarTree} bind:selectedCalendars={selectedCalendars} />
<div style="flex: 1;"> <div style="flex: 1;">
<FullCalendar bind:this={calendar} {options} /> <FullCalendar bind:this={calendar} {options} />
</div> </div>

View file

@ -117,7 +117,7 @@ export function mkEvent(title, start, duration, ...rest) {
export function refreshEvents(selectedCalendars) { export function refreshEvents(selectedCalendars) {
return Promise.all( return Promise.all(
calendarIds calendarIds
.filter(id => selectedCalendars ? selectedCalendars.includes(id) : true) .filter(id => selectedCalendars ? selectedCalendars.includes(calendars[id].name) : true)
.map(id => mkEventsFromCalendar(id, calendars[id])) .map(id => mkEventsFromCalendar(id, calendars[id]))
); );
} }