Skip to content

Commit

Permalink
recompute reqs (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabeth-tang authored Mar 15, 2024
1 parent e97cd36 commit 28a0312
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const store: TypedVuexStore = new TypedVuexStore({
setSemesters(state: VuexStoreState, semesters: readonly FirestoreSemester[]) {
const editedPlan: Plan = {
name: state.currentPlan.name,
semesters: sortedSemesters(semesters),
semesters: sortedSemesters(semesters, state.orderByNewest),
};
const editedPlans = state.plans.map(plan => (plan === state.currentPlan ? editedPlan : plan));
state.plans = editedPlans;
Expand All @@ -201,14 +201,15 @@ const autoRecomputeDerivedData = (): (() => void) =>
);
break;
}
case 'setSemesters': {
case 'setSemesters' || 'setPlans': {
const allCourseSet = new Set<string>();
const duplicatedCourseCodeSet = new Set<string>();
const courseMap: Record<number, FirestoreSemesterCourse> = {};
const courseToSemesterMap: Record<number, FirestoreSemester> = {};
(state.plans.length === 0
? []
: state.plans.find(p => p === state.currentPlan)?.semesters ?? state.plans[0].semesters
: state.plans.find(p => p.name === state.currentPlan.name)?.semesters ??
state.plans[0].semesters
).forEach(semester => {
semester.courses.forEach(course => {
if (isPlaceholderCourse(course)) {
Expand Down Expand Up @@ -241,15 +242,16 @@ const autoRecomputeDerivedData = (): (() => void) =>
mutation.type === 'setSemesters' ||
mutation.type === 'setToggleableRequirementChoices' ||
mutation.type === 'setOverriddenFulfillmentChoices' ||
mutation.type === 'setCurrentPlan'
mutation.type === 'setCurrentPlan' ||
mutation.type === 'setPlans'
) {
if (state.onboardingData.college !== '') {
store.commit(
'setRequirementData',
computeGroupedRequirementFulfillmentReports(
state.plans.length === 0
? []
: state.plans.find(p => p === state.currentPlan)?.semesters ??
: state.plans.find(p => p.name === state.currentPlan.name)?.semesters ??
state.plans[0].semesters,
state.onboardingData,
state.toggleableRequirementChoices,
Expand Down

0 comments on commit 28a0312

Please sign in to comment.