From 1f67537a262e260d286a4f066ed50efc4d708320 Mon Sep 17 00:00:00 2001 From: WinterWolfSV Date: Fri, 20 Sep 2024 23:27:40 +0200 Subject: [PATCH] Fix the calendar not displaying the specified amount of data depending on the includePast variable --- .../components/common/components/calendar/calendar.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/components/common/components/calendar/calendar.tsx b/web/src/components/common/components/calendar/calendar.tsx index f1aa4ee..461879c 100644 --- a/web/src/components/common/components/calendar/calendar.tsx +++ b/web/src/components/common/components/calendar/calendar.tsx @@ -32,9 +32,14 @@ const Calendar: React.FC> = ({ calendarUrl }) => { setIncludePast(value) } + // Function added to verify based on the local storage if the full calendar should be loaded or not + const shouldIncludePast = () => { + return window.localStorage.getItem("includePast") !== "false" + } + // Triggers on page load to update the includePast variable to the value last set by the user useEffect(() => { - setIncludePast(window.localStorage.getItem("includePast") === "true") + setIncludePast(shouldIncludePast) }, []); /** @@ -60,7 +65,7 @@ const Calendar: React.FC> = ({ calendarUrl }) => { setEvents(events); }; - getCalendarInfo(includePast); + getCalendarInfo(shouldIncludePast()); }, [calendarUrl, includePast]); /**