From b146a6a2a5180b09da1184946dc61272ad700b1b Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 12:40:18 +0100 Subject: [PATCH 01/16] fix: install pinia-plugin-persistedstate dependency --- frontend/package-lock.json | 9 +++++++++ frontend/package.json | 1 + 2 files changed, 10 insertions(+) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 072d71a43..91db229fe 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -22,6 +22,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", @@ -11114,6 +11115,14 @@ } } }, + "node_modules/pinia-plugin-persistedstate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", + "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", + "peerDependencies": { + "pinia": "^2.0.0" + } + }, "node_modules/pinia/node_modules/vue-demi": { "version": "0.14.6", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz", diff --git a/frontend/package.json b/frontend/package.json index 168c7cf64..b8ce0bd51 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", From e0e50b97665429856ed630ffbb3536b7c94fd2b4 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 12:41:11 +0100 Subject: [PATCH 02/16] fix: add plugin to our pinia instance --- frontend/src/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 570da770c..97dbfc93a 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -13,6 +13,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"; @@ -37,6 +38,7 @@ setupInterceptors(); const app = createApp(App); const pinia = createPinia(); +pinia.use(piniaPluginPersistedstate); app .use(VueAxios, axios) From e999452c2cca725128e20bb84208c745e888b5ba Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 12:49:51 +0100 Subject: [PATCH 03/16] fix: setting up persistence configuration --- frontend/src/store/index.ts | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index abd363ae8..f2652b640 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -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; From 14fbdaeecb54653412742dd6f58c8da50d645ba6 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 13:07:15 +0100 Subject: [PATCH 04/16] fix: persist the whole state to the session storage whenever something changes --- frontend/src/main.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 97dbfc93a..0a8a05443 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -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"; @@ -48,3 +49,10 @@ 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 } +) From 0cacce8fde59b0c79b5eb84f32b92f64f43a8cf4 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 13:17:41 +0100 Subject: [PATCH 05/16] fix: load userstories after page refresh --- frontend/src/views/SessionPage.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/views/SessionPage.vue b/frontend/src/views/SessionPage.vue index 635ac851e..c7a14a10f 100644 --- a/frontend/src/views/SessionPage.vue +++ b/frontend/src/views/SessionPage.vue @@ -475,6 +475,7 @@ export default defineComponent({ console.log("ON MOUNTED"); this.estimateFinished = true; } + this.refreshUserStories(); }, destroyed() { window.removeEventListener("beforeunload", this.sendUnregisterCommand); From 4eb5264948ecd4ca71c4f9fe327099b0eedd7a31 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 14:42:15 +0100 Subject: [PATCH 06/16] fix: only refresh userstories if userstory mode is active --- frontend/src/views/SessionPage.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/SessionPage.vue b/frontend/src/views/SessionPage.vue index c7a14a10f..38a082d51 100644 --- a/frontend/src/views/SessionPage.vue +++ b/frontend/src/views/SessionPage.vue @@ -475,9 +475,11 @@ export default defineComponent({ console.log("ON MOUNTED"); this.estimateFinished = true; } - this.refreshUserStories(); + if (this.userStoryMode === "US_JIRA") { + this.refreshUserStories(); + } }, - destroyed() { + unmounted() { window.removeEventListener("beforeunload", this.sendUnregisterCommand); }, methods: { From 0cd2f9d45655a2777efe75339b93045c966adbbc Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 14:59:51 +0100 Subject: [PATCH 07/16] fix: clearing sessionStorage to prevent any misbehavior when creating a new session --- frontend/src/views/PrepareSessionPage.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/views/PrepareSessionPage.vue b/frontend/src/views/PrepareSessionPage.vue index ebbe49772..40a254d27 100644 --- a/frontend/src/views/PrepareSessionPage.vue +++ b/frontend/src/views/PrepareSessionPage.vue @@ -252,6 +252,7 @@ export default defineComponent({ } }, async sendCreateSessionRequest() { + sessionStorage.clear(); const url = Constants.backendURL + Constants.createSessionRoute; const sessionConfig = { set: this.selectedCardSetOptions, From 7bc65e28cde0cf8f1d51ff6f096232fd6332241e Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 15:43:35 +0100 Subject: [PATCH 08/16] fix: lints --- frontend/src/main.ts | 8 +++++--- frontend/src/store/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 0a8a05443..144e42cce 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -50,9 +50,11 @@ app .use(Toast, {}) .mount("#app"); -watch(pinia.state, (state) => { +watch( + pinia.state, + (state) => { // persist the whole state to the session storage whenever it changes - sessionStorage.setItem("diveni-store", JSON.stringify(state["diveni-store"])) + sessionStorage.setItem("diveni-store", JSON.stringify(state["diveni-store"])); }, { deep: true } -) +); diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index f2652b640..06cad7615 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -26,7 +26,7 @@ export const useDiveniStore = defineStore("diveni-store", { hostEstimation: undefined as AdminVote | undefined, hostVoting: false, autoReveal: false, - } + }; }, persist: { storage: sessionStorage, //Storage where we store our "store-state" @@ -58,7 +58,7 @@ export const useDiveniStore = defineStore("diveni-store", { }, disconnectFromBackendWS() { this.stompClient?.disconnect(() => { - console.log("WebSocket Disconnected!") + console.log("WebSocket Disconnected!"); this.webSocketConnected = false; }); }, From 1c65e19f20dc07929aebe4248629c4f11fc03c4d Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 19:59:42 +0100 Subject: [PATCH 09/16] fix: only remove the 'diveni-store' from the session storage --- frontend/src/views/PrepareSessionPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/PrepareSessionPage.vue b/frontend/src/views/PrepareSessionPage.vue index 40a254d27..34f1fb136 100644 --- a/frontend/src/views/PrepareSessionPage.vue +++ b/frontend/src/views/PrepareSessionPage.vue @@ -252,7 +252,7 @@ export default defineComponent({ } }, async sendCreateSessionRequest() { - sessionStorage.clear(); + window.sessionStorage.removeItem("diveni-store"); const url = Constants.backendURL + Constants.createSessionRoute; const sessionConfig = { set: this.selectedCardSetOptions, From a7f984b54b6cca62b1c431e7107f7ce6a915a13c Mon Sep 17 00:00:00 2001 From: Dan1el Date: Sun, 10 Dec 2023 20:19:03 +0100 Subject: [PATCH 10/16] fix: only remove the 'diveni-store' - should automatically sync with the sessionStorage --- frontend/src/views/PrepareSessionPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/PrepareSessionPage.vue b/frontend/src/views/PrepareSessionPage.vue index 34f1fb136..70348c766 100644 --- a/frontend/src/views/PrepareSessionPage.vue +++ b/frontend/src/views/PrepareSessionPage.vue @@ -252,7 +252,7 @@ export default defineComponent({ } }, async sendCreateSessionRequest() { - window.sessionStorage.removeItem("diveni-store"); + this.store.clearStore(); const url = Constants.backendURL + Constants.createSessionRoute; const sessionConfig = { set: this.selectedCardSetOptions, From 7c445d7e4076d591526a15328467c33df2559f79 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 29 Feb 2024 12:36:20 +0100 Subject: [PATCH 11/16] fix: use the sendUnregisterCommand function in our sendCreateSessionRequest to avoid clearing our user stories in "Planning with User Stories" mode after page refresh --- frontend/src/views/PrepareSessionPage.vue | 7 ++++++- frontend/src/views/SessionPage.vue | 9 --------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/PrepareSessionPage.vue b/frontend/src/views/PrepareSessionPage.vue index 592deee28..71ce102dd 100644 --- a/frontend/src/views/PrepareSessionPage.vue +++ b/frontend/src/views/PrepareSessionPage.vue @@ -258,8 +258,13 @@ export default defineComponent({ return ["notSelectedTab", "notSelectedTextColor"]; } }, - async sendCreateSessionRequest() { + sendUnregisterCommand() { + const endPoint = `${Constants.webSocketUnregisterRoute}`; + this.store.sendViaBackendWS(endPoint); this.store.clearStore(); + }, + async sendCreateSessionRequest() { + this.sendUnregisterCommand(); const url = Constants.backendURL + Constants.createSessionRoute; const sessionConfig = { set: this.selectedCardSetOptions, diff --git a/frontend/src/views/SessionPage.vue b/frontend/src/views/SessionPage.vue index 1a18a3652..e835025a7 100644 --- a/frontend/src/views/SessionPage.vue +++ b/frontend/src/views/SessionPage.vue @@ -469,7 +469,6 @@ export default defineComponent({ } } this.timerCountdownNumber = parseInt(this.timerSecondsString ?? "0", 10); - window.addEventListener("beforeunload", this.sendUnregisterCommand); }, mounted() { if (this.rejoined === "false") { @@ -489,9 +488,6 @@ export default defineComponent({ this.refreshUserStories(); } }, - unmounted() { - window.removeEventListener("beforeunload", this.sendUnregisterCommand); - }, methods: { async checkAdminCookie() { console.log("checking admin cookie"); @@ -691,11 +687,6 @@ export default defineComponent({ subscribeWSNotification() { this.store.subscribeOnBackendWSNotify(); }, - sendUnregisterCommand() { - const endPoint = `${Constants.webSocketUnregisterRoute}`; - this.store.sendViaBackendWS(endPoint); - this.store.clearStore(); - }, sendVotingFinishedMessage() { if (!this.estimateFinished) { this.estimateFinished = true; From f1b0e5dee3897c8b74bc629f2cac417d0e793d0b Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 29 Feb 2024 12:59:09 +0100 Subject: [PATCH 12/16] fix: update pinia-plugin-persistedstate --- frontend/package-lock.json | 8 ++++---- frontend/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 5afc1a4e8..9187b4255 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -22,7 +22,7 @@ "hammerjs": "^2.0.8", "papaparse": "^5.4.1", "pinia": "^2.1.7", - "pinia-plugin-persistedstate": "^3.2.0", + "pinia-plugin-persistedstate": "^3.2.1", "popper.js": "^1.16.1", "qrcode.vue": "^3.4.1", "register-service-worker": "^1.7.1", @@ -11490,9 +11490,9 @@ } }, "node_modules/pinia-plugin-persistedstate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", - "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz", + "integrity": "sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==", "peerDependencies": { "pinia": "^2.0.0" } diff --git a/frontend/package.json b/frontend/package.json index bfbd92b87..14d33ced0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -26,7 +26,7 @@ "hammerjs": "^2.0.8", "papaparse": "^5.4.1", "pinia": "^2.1.7", - "pinia-plugin-persistedstate": "^3.2.0", + "pinia-plugin-persistedstate": "^3.2.1", "popper.js": "^1.16.1", "qrcode.vue": "^3.4.1", "register-service-worker": "^1.7.1", From d309c3c5f302a09ea79d456650d3ea4a22dd2d48 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 29 Feb 2024 13:05:52 +0100 Subject: [PATCH 13/16] fix: move to localStorage --- frontend/src/main.ts | 4 ++-- frontend/src/store/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 144e42cce..5892af97a 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -53,8 +53,8 @@ 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"])); + // persist the whole state to the local storage whenever it changes + localStorage.setItem("diveni-store", JSON.stringify(state["diveni-store"])); }, { deep: true } ); diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index 163fd4441..8d00f4fe0 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -29,7 +29,7 @@ export const useDiveniStore = defineStore("diveni-store", { }; }, persist: { - storage: sessionStorage, //Storage where we store our "store-state" + storage: localStorage, //Storage where we store our "store-state" }, actions: { setMembers(members) { From ae1dc2b6bc21fb34208454ad8c9b706c7e611200 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 29 Feb 2024 15:57:41 +0100 Subject: [PATCH 14/16] fix: reimplement UnregisterCommand --- frontend/src/views/SessionPage.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/views/SessionPage.vue b/frontend/src/views/SessionPage.vue index e835025a7..5c054f173 100644 --- a/frontend/src/views/SessionPage.vue +++ b/frontend/src/views/SessionPage.vue @@ -469,6 +469,7 @@ export default defineComponent({ } } this.timerCountdownNumber = parseInt(this.timerSecondsString ?? "0", 10); + window.addEventListener("beforeunload", this.sendUnregisterCommand); }, mounted() { if (this.rejoined === "false") { @@ -488,6 +489,9 @@ export default defineComponent({ this.refreshUserStories(); } }, + unmounted() { + window.removeEventListener("beforeunload", this.sendUnregisterCommand); + }, methods: { async checkAdminCookie() { console.log("checking admin cookie"); @@ -687,6 +691,11 @@ export default defineComponent({ subscribeWSNotification() { this.store.subscribeOnBackendWSNotify(); }, + sendUnregisterCommand() { + const endPoint = `${Constants.webSocketUnregisterRoute}`; + this.store.sendViaBackendWS(endPoint); + this.store.clearStoreWithoutUserStories(); + }, sendVotingFinishedMessage() { if (!this.estimateFinished) { this.estimateFinished = true; From d172e1e29acc3f1d0ef385db83909c931bc8a9e2 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 29 Feb 2024 16:40:00 +0100 Subject: [PATCH 15/16] fix: persist and automatically retrieve the selected user story on page refresh --- frontend/src/components/UserStories.vue | 8 ++++++-- frontend/src/store/index.ts | 4 ++++ frontend/src/views/LandingPage.vue | 5 +---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/UserStories.vue b/frontend/src/components/UserStories.vue index f86ea7efb..1da1cba65 100644 --- a/frontend/src/components/UserStories.vue +++ b/frontend/src/components/UserStories.vue @@ -55,7 +55,7 @@ readonly size="sm" :placeholder="t('page.session.before.userStories.placeholder.userStoryTitle')" - @blur="publishChanges(index, false)" + @click="publishChanges(index, false)" /> @@ -111,6 +111,7 @@ From 961261a019df12bce813ae217196768f15297be9 Mon Sep 17 00:00:00 2001 From: Dan1el Date: Thu, 28 Mar 2024 13:18:09 +0100 Subject: [PATCH 16/16] resolve merge conflict --- frontend/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 24ab147c3..7953d40a7 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -3,7 +3,7 @@ Diveni - The Planing-Poker App Copyright (C) 2022 AUME-Team 21/22, HTWG Konstanz */ -import Vue, { createApp } from "vue"; +import Vue, { createApp, watch } from "vue"; import axios from "axios"; import VueAxios from "vue-axios"; import App from "./App.vue";