From 353726596d769f82351bb7e2da6e4174202a6076 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 30 Aug 2024 21:55:08 -0600 Subject: [PATCH] remove the last of the localStorage for passing parameters --- src/store/app.ts | 20 -------------------- src/views/ContactGiftingView.vue | 8 ++++---- src/views/DiscoverView.vue | 1 - src/views/NewEditProjectView.vue | 12 +++++------- src/views/ProjectViewView.vue | 9 +++++---- src/views/ProjectsView.vue | 2 -- 6 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 src/store/app.ts diff --git a/src/store/app.ts b/src/store/app.ts deleted file mode 100644 index 0ed6c46..0000000 --- a/src/store/app.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check -import { defineStore } from "pinia"; - -export const useAppStore = defineStore({ - id: "app", - state: () => ({ - _projectId: - typeof localStorage.getItem("projectId") === "undefined" - ? "" - : localStorage.getItem("projectId"), - }), - getters: { - projectId: (state): string => state._projectId as string, - }, - actions: { - async setProjectId(newProjectId: string) { - localStorage.setItem("projectId", newProjectId); - }, - }, -}); diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index 1c2abfe..3441a72 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -92,8 +92,8 @@ export default class ContactGiftingView extends Vue { allContacts: Array = []; apiServer = ""; description = ""; - projectId = localStorage.getItem("projectId") || ""; - prompt = "What was given"; + projectId = ""; + prompt = ""; async created() { try { @@ -109,9 +109,9 @@ export default class ContactGiftingView extends Vue { (a.name || "").localeCompare(b.name || ""), ); - this.prompt = (this.$route as Router).query["prompt"] ?? this.prompt; + this.projectId = (this.$route as Router).query["projectId"] || ""; - localStorage.removeItem("projectId"); + this.prompt = (this.$route as Router).query["prompt"] ?? this.prompt; // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index c6d0a63..6268018 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -405,7 +405,6 @@ export default class DiscoverView extends Vue { * @param id of the project **/ onClickLoadProject(id: string) { - localStorage.setItem("projectId", id); const route = { path: "/project/" + encodeURIComponent(id), }; diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index c486135..a6579dd 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -192,7 +192,6 @@ import { getHeaders, PlanVerifiableCredential, } from "@/libs/endorserServer"; -import { useAppStore } from "@/store/app"; @Component({ components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav }, @@ -224,7 +223,7 @@ export default class NewEditProjectView extends Vue { latitude = 0; longitude = 0; numAccounts = 0; - projectId = localStorage.getItem("projectId") || ""; + projectId = ""; projectIssuerDid = ""; startDateInput?: string; startTimeInput?: string; @@ -240,6 +239,8 @@ export default class NewEditProjectView extends Vue { this.activeDid = (settings?.activeDid as string) || ""; this.apiServer = (settings?.apiServer as string) || ""; + this.projectId = (this.$route as Router).query["projectId"] || ""; + if (this.projectId) { if (this.numAccounts === 0) { this.errNote("There was a problem loading your account info."); @@ -421,11 +422,8 @@ export default class NewEditProjectView extends Vue { if (resp.data?.success?.handleId) { this.errorMessage = ""; - useAppStore() - .setProjectId(resp.data.success.handleId) - .then(() => { - (this.$router as Router).push({ name: "project" }); - }); + const projectPath = encodeURIComponent(resp.data.success.handleId); + (this.$router as Router).push({ path: "/project/" + projectPath }); } else { console.error( "Got unexpected 'data' inside response from server", diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 1a9c8f4..d6ff3da 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -483,7 +483,7 @@ export default class ProjectViewView extends Vue { name = ""; offersToThis: Array = []; offersHitLimit = false; - projectId = localStorage.getItem("projectId") || ""; // handle ID + projectId = ""; // handle ID showDidCopy = false; startTime = ""; truncatedDesc = ""; @@ -514,9 +514,9 @@ export default class ProjectViewView extends Vue { } onEditClick() { - localStorage.setItem("projectId", this.projectId as string); const route = { name: "new-edit-project", + query: { projectId: this.projectId }, }; (this.$router as Router).push(route); } @@ -838,7 +838,6 @@ export default class ProjectViewView extends Vue { * @param id of the project **/ async onClickLoadProject(projectId: string) { - localStorage.setItem("projectId", projectId); const route = { path: "/project/" + encodeURIComponent(projectId), }; @@ -874,9 +873,11 @@ export default class ProjectViewView extends Vue { } onClickAllContactsGifting() { - localStorage.setItem("projectId", this.projectId); const route = { name: "contact-gift", + query: { + projectId: this.projectId, + }, }; (this.$router as Router).push(route); } diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 4c3dea1..d1083a7 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -383,7 +383,6 @@ export default class ProjectsView extends Vue { * @param id of the project **/ onClickLoadProject(id: string) { - localStorage.setItem("projectId", id); const route = { path: "/project/" + encodeURIComponent(id), }; @@ -394,7 +393,6 @@ export default class ProjectsView extends Vue { * Handling clicking on the new project button **/ onClickNewProject(): void { - localStorage.removeItem("projectId"); const route = { name: "new-edit-project", };