From 9f94aad88a1fe92d5edc1fdfec1fb568b6814132 Mon Sep 17 00:00:00 2001 From: Matthew Aaron Raymer Date: Mon, 19 Dec 2022 15:58:17 +0800 Subject: [PATCH] Subject line: Adding routing for post-registration. Had to add a bogus home page (left over boilerplate home) to fill the role of an initial load state. The app will look at the app Pinia state and if it is 'registered' and then send to the discovery page. --- src/router/index.ts | 14 ++++++++------ src/views/AccountViewView.vue | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index df9ae69..67cafda 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,12 +1,12 @@ import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; import { useAppStore } from "../store/app"; -import HomeView from "../views/HomeView.vue"; const routes: Array = [ { path: "/", name: "home", - component: HomeView, + component: () => + import(/* webpackChunkName: "start" */ "../views/DiscoverView.vue"), }, { path: "/about", @@ -111,26 +111,28 @@ const router = createRouter({ routes, }); -router.beforeEach(async (to) => { +router.beforeEach(async (to, from, next) => { const publicPages = ["/start", "/account", "/import-account"]; const isPublic = publicPages.includes(to.path); const appStore = useAppStore(); let return_path = "/start"; - + if (to.path === "/" && appStore.condition == "registered") { + return_path = "/account"; + } if (isPublic) { switch (appStore.condition) { case "uninitialized": return_path = ""; break; case "registered": - return_path = to.path; + next(); break; } } if (return_path == "") { return; } else { - return return_path; + next(); } }); diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 1bec4d4..34c5749 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -257,6 +257,7 @@ export default class AccountViewView extends Vue { const identity = JSON.parse(accounts[0].identity); this.address = identity.did; this.publicHex = identity.keys[0].publicKeyHex; + this.UPORT_ROOT_DERIVATION_PATH = identity.keys[0].meta.derivationPath; } } }