1
0
Fork 0

Lint code.

This commit is contained in:
Kitteh 2021-05-16 10:35:35 +01:00
parent 3b251ee46f
commit 2d0733bfc7
5 changed files with 15 additions and 26 deletions

View file

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

View file

@ -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;

View file

@ -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<HTMLElement> {
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");

View file

@ -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";

View file

@ -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");