Browse Source

remove the last of the localStorage for passing parameters

Trent Larson 3 months ago
parent
commit
353726596d
  1. 20
      src/store/app.ts
  2. 8
      src/views/ContactGiftingView.vue
  3. 1
      src/views/DiscoverView.vue
  4. 12
      src/views/NewEditProjectView.vue
  5. 9
      src/views/ProjectViewView.vue
  6. 2
      src/views/ProjectsView.vue

20
src/store/app.ts

@ -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);
},
},
});

8
src/views/ContactGiftingView.vue

@ -92,8 +92,8 @@ export default class ContactGiftingView extends Vue {
allContacts: Array<Contact> = []; allContacts: Array<Contact> = [];
apiServer = ""; apiServer = "";
description = ""; description = "";
projectId = localStorage.getItem("projectId") || ""; projectId = "";
prompt = "What was given"; prompt = "";
async created() { async created() {
try { try {
@ -109,9 +109,9 @@ export default class ContactGiftingView extends Vue {
(a.name || "").localeCompare(b.name || ""), (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 // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) { } catch (err: any) {

1
src/views/DiscoverView.vue

@ -405,7 +405,6 @@ export default class DiscoverView extends Vue {
* @param id of the project * @param id of the project
**/ **/
onClickLoadProject(id: string) { onClickLoadProject(id: string) {
localStorage.setItem("projectId", id);
const route = { const route = {
path: "/project/" + encodeURIComponent(id), path: "/project/" + encodeURIComponent(id),
}; };

12
src/views/NewEditProjectView.vue

@ -192,7 +192,6 @@ import {
getHeaders, getHeaders,
PlanVerifiableCredential, PlanVerifiableCredential,
} from "@/libs/endorserServer"; } from "@/libs/endorserServer";
import { useAppStore } from "@/store/app";
@Component({ @Component({
components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav }, components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav },
@ -224,7 +223,7 @@ export default class NewEditProjectView extends Vue {
latitude = 0; latitude = 0;
longitude = 0; longitude = 0;
numAccounts = 0; numAccounts = 0;
projectId = localStorage.getItem("projectId") || ""; projectId = "";
projectIssuerDid = ""; projectIssuerDid = "";
startDateInput?: string; startDateInput?: string;
startTimeInput?: string; startTimeInput?: string;
@ -240,6 +239,8 @@ export default class NewEditProjectView extends Vue {
this.activeDid = (settings?.activeDid as string) || ""; this.activeDid = (settings?.activeDid as string) || "";
this.apiServer = (settings?.apiServer as string) || ""; this.apiServer = (settings?.apiServer as string) || "";
this.projectId = (this.$route as Router).query["projectId"] || "";
if (this.projectId) { if (this.projectId) {
if (this.numAccounts === 0) { if (this.numAccounts === 0) {
this.errNote("There was a problem loading your account info."); 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) { if (resp.data?.success?.handleId) {
this.errorMessage = ""; this.errorMessage = "";
useAppStore() const projectPath = encodeURIComponent(resp.data.success.handleId);
.setProjectId(resp.data.success.handleId) (this.$router as Router).push({ path: "/project/" + projectPath });
.then(() => {
(this.$router as Router).push({ name: "project" });
});
} else { } else {
console.error( console.error(
"Got unexpected 'data' inside response from server", "Got unexpected 'data' inside response from server",

9
src/views/ProjectViewView.vue

@ -483,7 +483,7 @@ export default class ProjectViewView extends Vue {
name = ""; name = "";
offersToThis: Array<OfferSummaryRecord> = []; offersToThis: Array<OfferSummaryRecord> = [];
offersHitLimit = false; offersHitLimit = false;
projectId = localStorage.getItem("projectId") || ""; // handle ID projectId = ""; // handle ID
showDidCopy = false; showDidCopy = false;
startTime = ""; startTime = "";
truncatedDesc = ""; truncatedDesc = "";
@ -514,9 +514,9 @@ export default class ProjectViewView extends Vue {
} }
onEditClick() { onEditClick() {
localStorage.setItem("projectId", this.projectId as string);
const route = { const route = {
name: "new-edit-project", name: "new-edit-project",
query: { projectId: this.projectId },
}; };
(this.$router as Router).push(route); (this.$router as Router).push(route);
} }
@ -838,7 +838,6 @@ export default class ProjectViewView extends Vue {
* @param id of the project * @param id of the project
**/ **/
async onClickLoadProject(projectId: string) { async onClickLoadProject(projectId: string) {
localStorage.setItem("projectId", projectId);
const route = { const route = {
path: "/project/" + encodeURIComponent(projectId), path: "/project/" + encodeURIComponent(projectId),
}; };
@ -874,9 +873,11 @@ export default class ProjectViewView extends Vue {
} }
onClickAllContactsGifting() { onClickAllContactsGifting() {
localStorage.setItem("projectId", this.projectId);
const route = { const route = {
name: "contact-gift", name: "contact-gift",
query: {
projectId: this.projectId,
},
}; };
(this.$router as Router).push(route); (this.$router as Router).push(route);
} }

2
src/views/ProjectsView.vue

@ -383,7 +383,6 @@ export default class ProjectsView extends Vue {
* @param id of the project * @param id of the project
**/ **/
onClickLoadProject(id: string) { onClickLoadProject(id: string) {
localStorage.setItem("projectId", id);
const route = { const route = {
path: "/project/" + encodeURIComponent(id), path: "/project/" + encodeURIComponent(id),
}; };
@ -394,7 +393,6 @@ export default class ProjectsView extends Vue {
* Handling clicking on the new project button * Handling clicking on the new project button
**/ **/
onClickNewProject(): void { onClickNewProject(): void {
localStorage.removeItem("projectId");
const route = { const route = {
name: "new-edit-project", name: "new-edit-project",
}; };

Loading…
Cancel
Save