From 22163e2e9e9ffbfe533477f235b5321e20f1252a Mon Sep 17 00:00:00 2001 From: Dalton Adcock Date: Wed, 17 Jan 2024 13:39:27 -0800 Subject: [PATCH] refactored custom event map load --- apps/antalmanac/src/components/Map/Map.tsx | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/apps/antalmanac/src/components/Map/Map.tsx b/apps/antalmanac/src/components/Map/Map.tsx index f19689575..377ab1aba 100644 --- a/apps/antalmanac/src/components/Map/Map.tsx +++ b/apps/antalmanac/src/components/Map/Map.tsx @@ -152,34 +152,21 @@ export default function CourseMap() { const [calendarEvents, setCalendarEvents] = useState(AppStore.getCourseEventsInCalendar()); useEffect(() => { - const updateMarkers = () => { + const updateAllMarkers = () => { setMarkers(getCoursesPerBuilding()); - }; - - AppStore.on('addedCoursesChange', updateMarkers); - AppStore.on('currentScheduleIndexChange', updateMarkers); - AppStore.on('colorChange', updateMarkers); - - return () => { - AppStore.removeListener('addedCoursesChange', updateMarkers); - AppStore.removeListener('currentScheduleIndexChange', updateMarkers); - AppStore.removeListener('colorChange', updateMarkers); - }; - }, []); - - useEffect(() => { - const updateCustomEventMarkers = () => { setCustomEventMarkers(getCustomEventPerBuilding()); }; - AppStore.on('customEventsChange', updateCustomEventMarkers); - AppStore.on('currentScheduleIndexChange', updateCustomEventMarkers); - AppStore.on('colorChange', updateCustomEventMarkers); + AppStore.on('addedCoursesChange', updateAllMarkers); + AppStore.on('customEventsChange', updateAllMarkers); + AppStore.on('currentScheduleIndexChange', updateAllMarkers); + AppStore.on('colorChange', updateAllMarkers); return () => { - AppStore.removeListener('customEventsChange', updateCustomEventMarkers); - AppStore.removeListener('currentScheduleIndexChange', updateCustomEventMarkers); - AppStore.removeListener('colorChange', updateCustomEventMarkers); + AppStore.removeListener('addedCoursesChange', updateAllMarkers); + AppStore.removeListener('customEventsChange', updateAllMarkers); + AppStore.removeListener('currentScheduleIndexChange', updateAllMarkers); + AppStore.removeListener('colorChange', updateAllMarkers); }; }, []);