Skip to content

Commit d28ce08

Browse files
committed
fix(timetable): initialize default objects and arrays if undefined
1 parent 4ce23c1 commit d28ce08

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

website/src/reducers/timetables.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,11 @@ function timetables(
289289
draft.lessons[semester] = semTimetable(draft.lessons[semester], action);
290290
draft.colors[semester] = semColors(state.colors[semester], action);
291291
draft.hidden[semester] = semHiddenModules(state.hidden[semester], action);
292+
if (!draft.customisedModules) {
293+
draft.customisedModules = {};
294+
}
292295
draft.customisedModules[semester] = customisedModules(
293-
state.customisedModules[semester],
296+
state.customisedModules?.[semester],
294297
action,
295298
);
296299
});

website/src/views/timetable/TimetableContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ function mapStateToProps(state: StoreState, ownProps: OwnProps) {
517517
modules,
518518
activeLesson: state.app.activeLesson,
519519
customiseModule: state.app.customiseModule,
520-
customisedModules: state.timetables.customisedModules[semester],
520+
customisedModules: state.timetables.customisedModules?.[semester] ?? [],
521521
timetableOrientation: state.theme.timetableOrientation,
522522
showTitle: state.theme.showTitle,
523523
hiddenInTimetable,

0 commit comments

Comments
 (0)