Skip to content

Commit 3d05c4f

Browse files
committed
timetables: add customisedModules prop when migrating to V2 schema
1 parent 4ce23c1 commit 3d05c4f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

website/src/reducers/timetables.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createMigrate, PersistedState } from 'redux-persist';
55
import { PersistConfig } from 'storage/persistReducer';
66
import { ModuleCode } from 'types/modules';
77
import { ModuleLessonConfig, SemTimetableConfig, TimetableConfig } from 'types/timetables';
8-
import { ColorMapping, TimetablesState } from 'types/reducers';
8+
import { ColorMapping, CustomisedModulesMap, TimetablesState } from 'types/reducers';
99

1010
import config from 'config';
1111
import {
@@ -35,8 +35,11 @@ export function migrateV1toV2(
3535
): TimetablesState & PersistedState {
3636
const newLessons: TimetableConfig = {};
3737
const oldLessons = oldState.lessons;
38+
const newCustomisedModules: CustomisedModulesMap = {};
3839

3940
Object.entries(oldLessons).forEach(([semester, modules]) => {
41+
newCustomisedModules[semester] = [];
42+
4043
Object.entries(modules).forEach(([moduleCode, lessons]) => {
4144
const newSemester: { [moduleCode: string]: { [lessonType: string]: string[] } } = {
4245
[moduleCode]: {},
@@ -56,6 +59,7 @@ export function migrateV1toV2(
5659
return {
5760
...oldState,
5861
lessons: newLessons,
62+
customisedModules: newCustomisedModules,
5963
};
6064
}
6165

0 commit comments

Comments
 (0)