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 all 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 @@ -25,6 +25,7 @@
"hammerjs": "^2.0.8",
"papaparse": "^5.4.1",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"popper.js": "^1.16.1",
"qrcode.vue": "^3.4.1",
"register-service-worker": "^1.7.1",
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/UserStories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
readonly
size="sm"
:placeholder="t('page.session.before.userStories.placeholder.userStoryTitle')"
@blur="publishChanges(index, false)"
@click="publishChanges(index, false)"
/>

<b-badge id="badge" class="p-2">
Expand Down Expand Up @@ -111,6 +111,7 @@

<script lang="ts">
import { defineComponent } from "vue";
import { useDiveniStore } from "@/store";
import UserStory from "../model/UserStory";
import { useI18n } from "vue-i18n";

Expand All @@ -124,8 +125,9 @@ export default defineComponent({
hostSelectedStoryIndex: { type: Number, required: false, default: null },
},
setup() {
const store = useDiveniStore();
const { t } = useI18n();
return { t };
return { store, t };
},
data() {
return {
Expand All @@ -149,6 +151,7 @@ export default defineComponent({
},
mounted() {
this.userStories = this.initialStories as Array<UserStory>;
this.selectedStoryIndex = this.store.selectedUserStoryIndex;
},
methods: {
setUserStoryAsActive(index) {
Expand Down Expand Up @@ -197,6 +200,7 @@ export default defineComponent({
this.publishChanges(index, true);
},
publishChanges(index, remove) {
this.store.setUserStoryIndex(index);
this.$emit("userStoriesChanged", { us: this.userStories, idx: index, doRemove: remove });
},
markUserStory(index) {
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
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";
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";
import "./assets/style/main.scss";
import Toast from "vue-toastification";
Expand All @@ -28,6 +29,7 @@ setupInterceptors();
const app = createApp(App);

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

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

watch(
pinia.state,
(state) => {
// persist the whole state to the local storage whenever it changes
localStorage.setItem("diveni-store", JSON.stringify(state["diveni-store"]));
},
{ deep: true }
);
43 changes: 26 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: localStorage, //Storage where we store our "store-state"
},
actions: {
setMembers(members) {
this.members = members;
Expand Down Expand Up @@ -117,6 +122,7 @@ export const useDiveniStore = defineStore("diveni-store", {
this.notifications = [];
this.webSocketConnected = false;
this.stompClient = undefined;
this.selectedUserStoryIndex = null;
},
clearStoreWithoutUserStories() {
this.members = [];
Expand All @@ -134,6 +140,9 @@ export const useDiveniStore = defineStore("diveni-store", {
setUserStories({ stories }) {
this.userStories = stories;
},
setUserStoryIndex(idx) {
this.selectedUserStoryIndex = idx;
},
setTokenId(tokenId) {
this.tokenId = tokenId;
},
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/views/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default defineComponent({
};
},
created() {
this.disconnectFromBackendWS();
this.store.clearStoreWithoutUserStories();
this.checkAdminCookie();
},
methods: {
Expand Down Expand Up @@ -228,9 +228,6 @@ export default defineComponent({
},
});
},
disconnectFromBackendWS() {
this.store.disconnectFromBackendWS();
},
},
});
</script>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/views/PrepareSessionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ export default defineComponent({
return ["notSelectedTab", "notSelectedTextColor"];
}
},
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,
Expand Down
7 changes: 5 additions & 2 deletions 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 Expand Up @@ -691,7 +694,7 @@ export default defineComponent({
sendUnregisterCommand() {
const endPoint = `${Constants.webSocketUnregisterRoute}`;
this.store.sendViaBackendWS(endPoint);
this.store.clearStore();
this.store.clearStoreWithoutUserStories();
},
sendVotingFinishedMessage() {
if (!this.estimateFinished) {
Expand Down
Loading