From 2f763c934060c1ec7b2e87986684bade22e33cf8 Mon Sep 17 00:00:00 2001 From: elizabeth-tang Date: Fri, 15 Mar 2024 20:32:08 -0400 Subject: [PATCH 1/2] fixed order by --- src/components/Requirements/MultiplePlansDropdown.vue | 1 + src/components/Requirements/RequirementSideBar.vue | 1 + src/global-firestore-data/user-semesters.ts | 1 + src/store.ts | 7 ++++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Requirements/MultiplePlansDropdown.vue b/src/components/Requirements/MultiplePlansDropdown.vue index a3923270f..347ea0676 100644 --- a/src/components/Requirements/MultiplePlansDropdown.vue +++ b/src/components/Requirements/MultiplePlansDropdown.vue @@ -87,6 +87,7 @@ export default defineComponent({ 'setCurrentPlan', store.state.plans.find(p => p.name === plan) ); + store.commit('setOrderByNewest', store.state.orderByNewest); this.shown = !this.shown; } }, diff --git a/src/components/Requirements/RequirementSideBar.vue b/src/components/Requirements/RequirementSideBar.vue index 8e5187a66..ab86deabe 100644 --- a/src/components/Requirements/RequirementSideBar.vue +++ b/src/components/Requirements/RequirementSideBar.vue @@ -393,6 +393,7 @@ export default defineComponent({ 'setCurrentPlan', store.state.plans.find(plan => plan.name === name) ); + store.commit('setOrderByNewest', store.state.orderByNewest); this.confirmationText = `${oldname} has been renamed to ${name}!`; this.isConfirmationOpen = true; setTimeout(() => { diff --git a/src/global-firestore-data/user-semesters.ts b/src/global-firestore-data/user-semesters.ts index 98ede8ae5..f03e663ae 100644 --- a/src/global-firestore-data/user-semesters.ts +++ b/src/global-firestore-data/user-semesters.ts @@ -28,6 +28,7 @@ export const editPlans = async ( await updateDoc(doc(semestersCollection, store.state.currentFirebaseUser.email), { plans, }); + store.commit('setOrderByNewest', store.state.orderByNewest); }; /** * Sets whether semesters are ordered by newest/oldest diff --git a/src/store.ts b/src/store.ts index c07494b43..b9d33b58c 100644 --- a/src/store.ts +++ b/src/store.ts @@ -177,7 +177,9 @@ const store: TypedVuexStore = new TypedVuexStore({ name: state.currentPlan.name, semesters: sortedSemesters(semesters, state.orderByNewest), }; - const editedPlans = state.plans.map(plan => (plan === state.currentPlan ? editedPlan : plan)); + const editedPlans = state.plans.map(plan => + plan.name === state.currentPlan.name ? editedPlan : plan + ); state.plans = editedPlans; state.currentPlan = editedPlan; }, @@ -199,6 +201,9 @@ const autoRecomputeDerivedData = (): (() => void) => 'setSemesters', sortedSemesters(store.getters.getCurrentPlanSemesters, state.orderByNewest) ); + console.log(store.getters.getCurrentPlanSemesters); + console.log(store.state.orderByNewest); + console.log(sortedSemesters(store.getters.getCurrentPlanSemesters, state.orderByNewest)); break; } case 'setSemesters' || 'setPlans': { From b7e1e28640cd6fc6ecf39ac4157e34a7db12dbe9 Mon Sep 17 00:00:00 2001 From: elizabeth-tang Date: Fri, 15 Mar 2024 20:36:39 -0400 Subject: [PATCH 2/2] delete console --- src/store.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/store.ts b/src/store.ts index b9d33b58c..6a5dc8d26 100644 --- a/src/store.ts +++ b/src/store.ts @@ -201,9 +201,6 @@ const autoRecomputeDerivedData = (): (() => void) => 'setSemesters', sortedSemesters(store.getters.getCurrentPlanSemesters, state.orderByNewest) ); - console.log(store.getters.getCurrentPlanSemesters); - console.log(store.state.orderByNewest); - console.log(sortedSemesters(store.getters.getCurrentPlanSemesters, state.orderByNewest)); break; } case 'setSemesters' || 'setPlans': {