Skip to content

Commit

Permalink
fixed custom event initial/change map load
Browse files Browse the repository at this point in the history
  • Loading branch information
adcockdalton committed Jan 17, 2024
1 parent b08e18e commit c6cb5a8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apps/antalmanac/src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default function CourseMap() {
const [searchParams] = useSearchParams();
const [selectedDayIndex, setSelectedDay] = useState(0);
const [markers, setMarkers] = useState(getCoursesPerBuilding());
const [customEventMarkers] = useState(getCustomEventPerBuilding());
const [customEventMarkers, setCustomEventMarkers] = useState(getCustomEventPerBuilding());
const [calendarEvents, setCalendarEvents] = useState(AppStore.getCourseEventsInCalendar());

useEffect(() => {
Expand All @@ -167,6 +167,22 @@ export default function CourseMap() {
};
}, []);

useEffect(() => {
const updateCustomEventMarkers = () => {
setCustomEventMarkers(getCustomEventPerBuilding());
};

AppStore.on('customEventsChange', updateCustomEventMarkers);
AppStore.on('currentScheduleIndexChange', updateCustomEventMarkers);
AppStore.on('colorChange', updateCustomEventMarkers);

return () => {
AppStore.removeListener('customEventsChange', updateCustomEventMarkers);
AppStore.removeListener('currentScheduleIndexChange', updateCustomEventMarkers);
AppStore.removeListener('colorChange', updateCustomEventMarkers);
};
}, []);

useEffect(() => {
const updateCalendarEvents = () => {
setCalendarEvents(AppStore.getCourseEventsInCalendar());
Expand Down

0 comments on commit c6cb5a8

Please sign in to comment.