diff --git a/src/PageState.ts b/src/PageState.ts index 7105515..03c4bd6 100644 --- a/src/PageState.ts +++ b/src/PageState.ts @@ -1,7 +1,3 @@ -import { Page } from "./types/Page"; -import { allPages } from "./allPages"; -import { getKeyByObjectPropertyValue } from "./utils"; - export class PageState { constructor() { // Do Nothing @@ -96,19 +92,13 @@ export class PageState { localStorage.setItem("currentMountType", value); } get currentPageString(): string { - const key = getKeyByObjectPropertyValue(allPages, this.currentPage); - return key; + return this.currentPage; } - get currentPage(): Page | string { + get currentPage(): string { const curPage = localStorage.getItem("currentPage") || "HOME"; - return allPages[curPage]; + return curPage; } - set currentPage(value: Page | string) { - if (typeof value == "object") { - const key = getKeyByObjectPropertyValue(allPages, value); - localStorage.setItem("currentPage", key); - } else { - localStorage.setItem("currentPage", value); - } + set currentPage(value: string) { + localStorage.setItem("currentPage", value); } } diff --git a/src/allPages.ts b/src/allPages.ts index 286f7fa..0538e80 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -25,7 +25,10 @@ import { TransitViewPage } from "./pages/Transit/TransitView"; import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret"; import { UnsealPage } from "./pages/Unseal"; import { getObjectKeys } from "./utils"; + +/* eslint-disable */ import { PageType } from "z-pagerouter"; +/* eslint-enable */ type pagesList = { [key: string]: Page; diff --git a/src/elements/SecretTitleElement.ts b/src/elements/SecretTitleElement.ts index 9c78188..e746b78 100644 --- a/src/elements/SecretTitleElement.ts +++ b/src/elements/SecretTitleElement.ts @@ -1,17 +1,16 @@ import { PageRouter } from "z-pagerouter"; -import { makeElement } from "../htmlUtils"; import { PageState } from "../PageState"; +import { makeElement } from "../htmlUtils"; function currentTitleSecretText(state: PageState, suffix = ""): string { let currentSecretText = state.currentSecret; currentSecretText += suffix; - if (state.currentSecretVersion !== null) - currentSecretText += ` (v${state.currentSecretVersion})`; + if (state.currentSecretVersion !== null) currentSecretText += ` (v${state.currentSecretVersion})`; return currentSecretText; } export async function SecretTitleElement(router: PageRouter, suffix = ""): Promise { - let state = router.state as PageState; + const state = router.state as PageState; const titleElement = makeElement({ tag: "div", children: [ @@ -23,10 +22,7 @@ export async function SecretTitleElement(router: PageRouter, suffix = ""): Promi state.currentSecret = ""; state.currentSecretVersion = null; - if ( - state.currentMountType.startsWith("kv") || - state.currentMountType == "cubbyhole" - ) { + if (state.currentMountType.startsWith("kv") || state.currentMountType == "cubbyhole") { await router.changePage("KEY_VALUE_VIEW"); } else if (state.currentMountType == "totp") { await router.changePage("TOTP"); diff --git a/src/main.ts b/src/main.ts index d6d7286..7d7c1a4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,10 +21,10 @@ Prism.highlightAll(); import { NavBar } from "./elements/NavBar"; import { PageRouter } from "z-pagerouter"; -import { pageList } from "./allPages"; import { formatDistance } from "./formatDistance"; import { getSealStatus } from "./api/sys/getSealStatus"; import { makeElement } from "./htmlUtils"; +import { pageList } from "./allPages"; import { pageState } from "./globalPageState"; import { playground } from "./playground"; import i18next from "i18next"; diff --git a/src/pageUtils.ts b/src/pageUtils.ts index c232798..87f838b 100644 --- a/src/pageUtils.ts +++ b/src/pageUtils.ts @@ -1,13 +1,13 @@ import { PageRouter } from "z-pagerouter"; +import { PageState } from "./PageState"; import { getSealStatus } from "./api/sys/getSealStatus"; import { lookupSelf } from "./api/sys/lookupSelf"; import ClipboardJS from "clipboard"; import UIkit from "uikit"; import i18next from "i18next"; -import { PageState } from "./PageState"; async function prePageChecksReal(router: PageRouter) { - let state = router.state as PageState; + const state = router.state as PageState; if (state.language.length == 0) { await router.changePage("SET_LANGUAGE"); throw new Error("Language Not Set");