Skip to content

Commit

Permalink
fix(timetable): initialize default objects and arrays if undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
zwliew committed Aug 4, 2023
1 parent 4ce23c1 commit d28ce08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion website/src/reducers/timetables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,11 @@ function timetables(
draft.lessons[semester] = semTimetable(draft.lessons[semester], action);
draft.colors[semester] = semColors(state.colors[semester], action);
draft.hidden[semester] = semHiddenModules(state.hidden[semester], action);
if (!draft.customisedModules) {
draft.customisedModules = {};
}
draft.customisedModules[semester] = customisedModules(
state.customisedModules[semester],
state.customisedModules?.[semester],
action,
);
});
Expand Down
2 changes: 1 addition & 1 deletion website/src/views/timetable/TimetableContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ function mapStateToProps(state: StoreState, ownProps: OwnProps) {
modules,
activeLesson: state.app.activeLesson,
customiseModule: state.app.customiseModule,
customisedModules: state.timetables.customisedModules[semester],
customisedModules: state.timetables.customisedModules?.[semester] ?? [],
timetableOrientation: state.theme.timetableOrientation,
showTitle: state.theme.showTitle,
hiddenInTimetable,
Expand Down

0 comments on commit d28ce08

Please sign in to comment.