Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: After page refresh, store state no longer retains the selected project #566 #567

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b146a6a
fix: install pinia-plugin-persistedstate dependency
Dan1elBox Dec 10, 2023
e0e50b9
fix: add plugin to our pinia instance
Dan1elBox Dec 10, 2023
e999452
fix: setting up persistence configuration
Dan1elBox Dec 10, 2023
14fbdae
fix: persist the whole state to the session storage whenever somethin…
Dan1elBox Dec 10, 2023
0cacce8
fix: load userstories after page refresh
Dan1elBox Dec 10, 2023
4eb5264
fix: only refresh userstories if userstory mode is active
Dan1elBox Dec 10, 2023
0cd2f9d
fix: clearing sessionStorage to prevent any misbehavior when creating…
Dan1elBox Dec 10, 2023
7bc65e2
fix: lints
Dan1elBox Dec 10, 2023
1c65e19
fix: only remove the 'diveni-store' from the session storage
Dan1elBox Dec 10, 2023
a7f984b
fix: only remove the 'diveni-store' - should automatically sync with …
Dan1elBox Dec 10, 2023
f2dfe88
Merge remote-tracking branch 'origin/main' into 566-after-page-refres…
Dan1elBox Feb 22, 2024
a769488
Merge remote-tracking branch 'origin/main' into 566-after-page-refres…
Dan1elBox Feb 29, 2024
7c445d7
fix: use the sendUnregisterCommand function in our sendCreateSessionR…
Dan1elBox Feb 29, 2024
f1b0e5d
fix: update pinia-plugin-persistedstate
Dan1elBox Feb 29, 2024
d309c3c
fix: move to localStorage
Dan1elBox Feb 29, 2024
ae1dc2b
fix: reimplement UnregisterCommand
Dan1elBox Feb 29, 2024
d172e1e
fix: persist and automatically retrieve the selected user story on pa…
Dan1elBox Feb 29, 2024
8225885
Merge remote-tracking branch 'origin/main' into 566-after-page-refres…
Dan1elBox Mar 28, 2024
961261a
resolve merge conflict
Dan1elBox Mar 28, 2024
c1c2925
Merge remote-tracking branch 'origin/main' into 566-after-page-refres…
Dan1elBox Apr 25, 2024
aa90bd7
Merge remote-tracking branch 'origin/main' into 566-after-page-refres…
Dan1elBox May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"hammerjs": "^2.0.8",
"papaparse": "^5.4.1",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.0",
"popper.js": "^1.16.1",
"qrcode.vue": "^3.4.1",
"register-service-worker": "^1.7.1",
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (C) 2022 AUME-Team 21/22, HTWG Konstanz
*/
import Vue, { createApp } from "@vue/compat";
import { watch } from "vue";

import axios from "axios";
import VueAxios from "vue-axios";
Expand All @@ -13,6 +14,7 @@ import "./registerServiceWorker";
import router from "./router";
import setupInterceptors from "./interceptors";
import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";

import { BootstrapVue, IconsPlugin, ModalPlugin } from "bootstrap-vue";

Expand All @@ -37,6 +39,7 @@ setupInterceptors();
const app = createApp(App);

const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

app
.use(VueAxios, axios)
Expand All @@ -46,3 +49,12 @@ app
.use(i18n)
.use(Toast, {})
.mount("#app");

watch(
pinia.state,
(state) => {
// persist the whole state to the session storage whenever it changes
sessionStorage.setItem("diveni-store", JSON.stringify(state["diveni-store"]));
},
{ deep: true }
);
39 changes: 22 additions & 17 deletions frontend/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@ import Member from "@/model/Member";
import AdminVote from "@/model/AdminVote";

export const useDiveniStore = defineStore("diveni-store", {
state: () => ({
stompClient: undefined as Client | undefined,
webSocketConnected: false,
memberUpdates: [] as string[],
userStories: [] as UserStory[],
members: [] as Member[],
notifications: [] as Notification[],
highlightedMembers: [],
timerTimestamp: undefined as string | undefined,
tokenId: undefined,
projects: [],
selectedProject: undefined as Project | undefined,
selectedUserStoryIndex: null as number | null,
hostEstimation: undefined as AdminVote | undefined,
hostVoting: false,
autoReveal: false,
}),
state: () => {
return {
stompClient: undefined as Client | undefined,
webSocketConnected: false,
memberUpdates: [] as string[],
userStories: [] as UserStory[],
members: [] as Member[],
notifications: [] as Notification[],
highlightedMembers: [],
timerTimestamp: undefined as string | undefined,
tokenId: undefined,
projects: [],
selectedProject: undefined as Project | undefined,
selectedUserStoryIndex: null as number | null,
hostEstimation: undefined as AdminVote | undefined,
hostVoting: false,
autoReveal: false,
};
},
persist: {
storage: sessionStorage, //Storage where we store our "store-state"
},
actions: {
setMembers(members) {
this.members = members;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/PrepareSessionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export default defineComponent({
}
},
async sendCreateSessionRequest() {
this.store.clearStore();
const url = Constants.backendURL + Constants.createSessionRoute;
const sessionConfig = {
set: this.selectedCardSetOptions,
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/views/SessionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,11 @@ export default defineComponent({
console.log("ON MOUNTED");
this.estimateFinished = true;
}
if (this.userStoryMode === "US_JIRA") {
this.refreshUserStories();
}
},
destroyed() {
unmounted() {
window.removeEventListener("beforeunload", this.sendUnregisterCommand);
},
methods: {
Expand Down
Loading