Skip to content

Commit

Permalink
fix: deep copy nested object
Browse files Browse the repository at this point in the history
  • Loading branch information
yumincho committed Apr 25, 2024
1 parent 79b0b63 commit 048b859
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/reducers/timetable/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const list = (state = initialState, action: LectureListAction) => {
*/
case CLEAR_SEARCH_LIST_LECTURES: {
const newState = { ...state };
newState.lists = { ...newState.lists };
newState.lists[LectureListCode.SEARCH].lectureGroups = null;
return newState;

Check warning on line 102 in src/reducers/timetable/list.ts

View check run for this annotation

Codecov / codecov/patch

src/reducers/timetable/list.ts#L102

Added line #L102 was not covered by tests
}
Expand All @@ -106,6 +107,7 @@ const list = (state = initialState, action: LectureListAction) => {
const newLectures = [...lectures, action.lecture];
const newLectureGroups = groupLectures(newLectures);
const newState = { ...state };
newState.lists = { ...newState.lists };
newState.lists[LectureListCode.CART].lectureGroups = newLectureGroups;
return newState;

Check warning on line 112 in src/reducers/timetable/list.ts

View check run for this annotation

Codecov / codecov/patch

src/reducers/timetable/list.ts#L112

Added line #L112 was not covered by tests
}
Expand All @@ -115,6 +117,7 @@ const list = (state = initialState, action: LectureListAction) => {
const newLectures = lectures.filter((l) => l.id !== action.lecture.id);
const newLectureGroups = groupLectures(newLectures);
const newState = { ...state };
newState.lists = { ...newState.lists };
newState.lists[LectureListCode.CART].lectureGroups = newLectureGroups;
return newState;

Check warning on line 122 in src/reducers/timetable/list.ts

View check run for this annotation

Codecov / codecov/patch

src/reducers/timetable/list.ts#L122

Added line #L122 was not covered by tests
}
Expand Down

0 comments on commit 048b859

Please sign in to comment.