From b3470be6f1ba40dfdce75d5ca670556e7475ca7b Mon Sep 17 00:00:00 2001 From: Kitteh Date: Wed, 12 May 2021 17:37:09 +0100 Subject: [PATCH] Make changePage async. --- .eslintrc.json | 8 ++---- src/elements/NavBar.ts | 16 +++++------ src/main.ts | 10 +++---- src/pageUtils.ts | 34 +++++++++++------------ src/pages/Home.ts | 12 ++++---- src/pages/KeyValue/KeyValueDelete.ts | 10 +++---- src/pages/KeyValue/KeyValueNew.ts | 8 +++--- src/pages/KeyValue/KeyValueSecret.ts | 20 ++++++------- src/pages/KeyValue/KeyValueSecretsEdit.ts | 8 +++--- src/pages/KeyValue/KeyValueVersions.ts | 8 +++--- src/pages/KeyValue/KeyValueView.ts | 16 +++++------ src/pages/Login.ts | 6 ++-- src/pages/Me.ts | 12 ++++---- src/pages/PwGen.ts | 4 +-- src/pages/SetLanguage.ts | 4 +-- src/pages/SetVaultURL.ts | 4 +-- src/pages/TOTP/NewTOTP.ts | 8 +++--- src/pages/TOTP/TOTPView.ts | 7 +++-- src/pages/Transit/TransitDecrypt.ts | 6 ++-- src/pages/Transit/TransitEncrypt.ts | 6 ++-- src/pages/Transit/TransitRewrap.ts | 4 +-- src/pages/Transit/TransitView.ts | 8 +++--- src/pages/Transit/TransitViewSecret.ts | 10 +++---- src/pages/Unseal.ts | 4 +-- src/playground.ts | 2 +- src/types/Page.ts | 11 +++----- 26 files changed, 119 insertions(+), 127 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 47ce9c7..0ec9a70 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -28,12 +28,8 @@ "argsIgnorePattern": "^_" } ], - "@typescript-eslint/no-empty-function": [ - "error", - { - "allow": ["arrowFunctions"] - } - ], + "@typescript-eslint/require-await": ["off"], + "@typescript-eslint/no-empty-function": ["off"], "@typescript-eslint/ban-ts-comment": ["off"], "sort-imports-es6-autofix/sort-imports-es6": [2], "@typescript-eslint/no-explicit-any": [2], diff --git a/src/elements/NavBar.ts b/src/elements/NavBar.ts index a10e98d..71497b5 100644 --- a/src/elements/NavBar.ts +++ b/src/elements/NavBar.ts @@ -22,8 +22,8 @@ export function NavBar(): HTMLElement { makeElement({ tag: "a", text: i18next.t("home_btn"), - onclick: () => { - changePage("HOME"); + onclick: async () => { + await changePage("HOME"); }, }), ), @@ -31,8 +31,8 @@ export function NavBar(): HTMLElement { makeElement({ tag: "a", text: i18next.t("back_btn"), - onclick: () => { - (pageState.currentPage as Page).goBack(); + onclick: async () => { + await (pageState.currentPage as Page).goBack(); }, }), ), @@ -40,8 +40,8 @@ export function NavBar(): HTMLElement { makeElement({ tag: "a", text: i18next.t("refresh_btn"), - onclick: () => { - changePage(pageState.currentPageString); + onclick: async () => { + await changePage(pageState.currentPageString); }, }), ), @@ -59,8 +59,8 @@ export function NavBar(): HTMLElement { makeElement({ tag: "a", text: i18next.t("me_btn"), - onclick: () => { - changePage("ME"); + onclick: async () => { + await changePage("ME"); }, }), ), diff --git a/src/main.ts b/src/main.ts index f90eb58..f1f4155 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,7 +37,7 @@ declare global { } } -function onLoad(): void { +async function onLoad(): Promise { document.body.innerHTML = ""; document.body.appendChild(NavBar()); document.body.appendChild( @@ -66,10 +66,10 @@ function onLoad(): void { window.pageContent = document.querySelector("#pageContent"); if (process.env.NODE_ENV == "development") { - playground(); + await playground(); } - renderPage(); + await renderPage(); setInterval(() => { if (pageState.currentPageString != "UNSEAL") { @@ -78,7 +78,7 @@ function onLoad(): void { } void getSealStatus().then((sealStatus) => { if (sealStatus.sealed) { - changePage("UNSEAL"); + void changePage("UNSEAL"); return; } }); @@ -110,7 +110,7 @@ document.addEventListener( }, }) .then(function (_) { - onLoad(); + void onLoad(); }); }, false, diff --git a/src/pageUtils.ts b/src/pageUtils.ts index bd47694..7891b04 100644 --- a/src/pageUtils.ts +++ b/src/pageUtils.ts @@ -10,24 +10,24 @@ import i18next from "i18next"; async function prePageChecksReal() { if (pageState.language.length == 0) { - changePage("SET_LANGUAGE"); + await changePage("SET_LANGUAGE"); throw new Error("Language Not Set"); } if (!pageState.apiURL) { - changePage("SET_VAULT_URL"); + await changePage("SET_VAULT_URL"); throw new Error("Vault URL Not Set"); } const sealStatus = await getSealStatus(); if (sealStatus.sealed) { - changePage("UNSEAL"); + await changePage("UNSEAL"); throw new Error("Vault Sealed"); } try { await lookupSelf(); } catch (e) { - changePage("LOGIN"); + await changePage("LOGIN"); throw e; } } @@ -78,22 +78,20 @@ export function setErrorText(text: string): void { }); } -export function changePage(page: string, shouldSwitch = true): void { - if (pageState.currentPage && shouldSwitch) { - (pageState.currentPage as Page).cleanup(); +export async function changePage(page: string): Promise { + if (pageState.currentPage) { + await (pageState.currentPage as Page).cleanup(); } pageState.currentPage = page; - if (shouldSwitch) { - renderPage(); - } + await renderPage(); } -export function renderPage(): void { +export async function renderPage(): Promise { document.documentElement.dir = pageState.pageDirection; console.log("Rendering Page: ", (pageState.currentPage as Page).name); document.querySelector("#pageContent").innerHTML = ""; setPageTitle((pageState.currentPage as Page).name); - (pageState.currentPage as Page).render(); + await (pageState.currentPage as Page).render(); } export function setPageTitle(title: string | HTMLElement): void { @@ -121,7 +119,7 @@ export function setTitleElement(pageState: PageState): void { makeElement({ tag: "a", text: pageState.currentBaseMount + " ", - onclick: () => { + onclick: async () => { pageState.currentSecretPath = []; pageState.currentSecret = ""; pageState.currentSecretVersion = null; @@ -130,11 +128,11 @@ export function setTitleElement(pageState: PageState): void { pageState.currentMountType.startsWith("kv") || pageState.currentMountType == "cubbyhole" ) { - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } else if (pageState.currentMountType == "totp") { - changePage("TOTP"); + await changePage("TOTP"); } else if (pageState.currentMountType == "transit") { - changePage("TRANSIT_VIEW"); + await changePage("TRANSIT_VIEW"); } }, }), @@ -142,11 +140,11 @@ export function setTitleElement(pageState: PageState): void { return makeElement({ tag: "a", text: secretPath + " ", - onclick: () => { + onclick: async () => { pageState.currentSecretVersion = null; if (pageState.currentMountType.startsWith("kv")) { pageState.currentSecretPath = secretPaths.slice(0, index + 1); - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } }, }); diff --git a/src/pages/Home.ts b/src/pages/Home.ts index c25ee0a..8d1850c 100644 --- a/src/pages/Home.ts +++ b/src/pages/Home.ts @@ -33,8 +33,8 @@ export class HomePage extends Page { children: makeElement({ tag: "a", text: i18next.t("password_generator_btn"), - onclick: () => { - changePage("PW_GEN"); + onclick: async () => { + await changePage("PW_GEN"); }, }), }), @@ -57,7 +57,7 @@ export class HomePage extends Page { setErrorText(error.message); if (error.message == "permission denied") { pageState.token = ""; - changePage("LOGIN"); + await changePage("LOGIN"); } } @@ -85,7 +85,7 @@ export class HomePage extends Page { const mountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type; let linkText = ""; - let linkPage; + let linkPage: string; if (mount.type == "kv") { linkText = `K/V (v${mount.options.version}) - ${baseMount}`; linkPage = "KEY_VALUE_VIEW"; @@ -106,10 +106,10 @@ export class HomePage extends Page { children: makeElement({ tag: "a", text: linkText, - onclick: () => { + onclick: async () => { pageState.currentBaseMount = baseMount; pageState.currentMountType = mountType; - changePage(linkPage); + await changePage(linkPage); }, }), }), diff --git a/src/pages/KeyValue/KeyValueDelete.ts b/src/pages/KeyValue/KeyValueDelete.ts index 21342ec..d1bca45 100644 --- a/src/pages/KeyValue/KeyValueDelete.ts +++ b/src/pages/KeyValue/KeyValueDelete.ts @@ -9,16 +9,16 @@ export class KeyValueDeletePage extends Page { constructor() { super(); } - goBack(): void { + async goBack(): Promise { if (pageState.currentSecretVersion != null) { pageState.currentSecretVersion = null; - changePage("KEY_VALUE_SECRET"); + await changePage("KEY_VALUE_SECRET"); } else { pageState.currentSecret = ""; - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } } - render(): void { + async render(): Promise { setTitleElement(pageState); setPageContent( makeElement({ @@ -40,7 +40,7 @@ export class KeyValueDeletePage extends Page { pageState.currentSecret, pageState.currentSecretVersion, ).then(() => { - this.goBack(); + void this.goBack(); }); }, }), diff --git a/src/pages/KeyValue/KeyValueNew.ts b/src/pages/KeyValue/KeyValueNew.ts index 9c88feb..f27048c 100644 --- a/src/pages/KeyValue/KeyValueNew.ts +++ b/src/pages/KeyValue/KeyValueNew.ts @@ -10,13 +10,13 @@ export class KeyValueNewPage extends Page { super(); } - goBack(): void { - changePage("KEY_VALUE_VIEW"); + async goBack(): Promise { + await changePage("KEY_VALUE_VIEW"); } addKVNewForm: HTMLFormElement; - render(): void { + async render(): Promise { setTitleElement(pageState); this.addKVNewForm = makeElement({ tag: "form", @@ -76,7 +76,7 @@ export class KeyValueNewPage extends Page { path, keyData, ); - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } catch (e: unknown) { const error = e as Error; setErrorText(error.message); diff --git a/src/pages/KeyValue/KeyValueSecret.ts b/src/pages/KeyValue/KeyValueSecret.ts index 4ab8565..1bc1027 100644 --- a/src/pages/KeyValue/KeyValueSecret.ts +++ b/src/pages/KeyValue/KeyValueSecret.ts @@ -14,13 +14,13 @@ export class KeyValueSecretPage extends Page { constructor() { super(); } - goBack(): void { + async goBack(): Promise { if (pageState.currentSecretVersion != null) { pageState.currentSecretVersion = null; - changePage("KEY_VALUE_VERSIONS"); + await changePage("KEY_VALUE_VERSIONS"); } else { pageState.currentSecret = ""; - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } } async render(): Promise { @@ -68,8 +68,8 @@ export class KeyValueSecretPage extends Page { tag: "button", id: "deleteButton", class: ["uk-button", "uk-button-danger"], - onclick: () => { - changePage("KEY_VALUE_DELETE"); + onclick: async () => { + await changePage("KEY_VALUE_DELETE"); }, text: deleteButtonText, }), @@ -82,8 +82,8 @@ export class KeyValueSecretPage extends Page { tag: "button", id: "editButton", class: ["uk-button", "uk-margin", "uk-button-primary"], - onclick: () => { - changePage("KEY_VALUE_SECRET_EDIT"); + onclick: async () => { + await changePage("KEY_VALUE_SECRET_EDIT"); }, text: i18next.t("kv_secret_edit_btn"), }), @@ -96,8 +96,8 @@ export class KeyValueSecretPage extends Page { tag: "button", id: "versionsButton", class: ["uk-button", "uk-button-secondary"], - onclick: () => { - changePage("KEY_VALUE_VERSIONS"); + onclick: async () => { + await changePage("KEY_VALUE_VERSIONS"); }, text: i18next.t("kv_secret_versions_btn"), }), @@ -135,7 +135,7 @@ export class KeyValueSecretPage extends Page { pageState.currentSecret, pageState.currentSecretVersion, ).then((_) => { - changePage(pageState.currentPageString); + void changePage(pageState.currentPageString); }); }, }), diff --git a/src/pages/KeyValue/KeyValueSecretsEdit.ts b/src/pages/KeyValue/KeyValueSecretsEdit.ts index b6ffe92..302286c 100644 --- a/src/pages/KeyValue/KeyValueSecretsEdit.ts +++ b/src/pages/KeyValue/KeyValueSecretsEdit.ts @@ -12,10 +12,10 @@ export class KeyValueSecretEditPage extends Page { constructor() { super(); } - goBack(): void { - changePage("KEY_VALUE_SECRET"); + async goBack(): Promise { + await changePage("KEY_VALUE_SECRET"); } - render(): void { + async render(): Promise { setTitleElement(pageState); const loadingText = makeElement({ tag: "p", @@ -71,7 +71,7 @@ export class KeyValueSecretEditPage extends Page { JSON.parse(jar.toString()), ) .then((_) => { - changePage("KEY_VALUE_SECRET"); + void changePage("KEY_VALUE_SECRET"); return; }) .catch((e: Error) => { diff --git a/src/pages/KeyValue/KeyValueVersions.ts b/src/pages/KeyValue/KeyValueVersions.ts index 08bcc01..3040628 100644 --- a/src/pages/KeyValue/KeyValueVersions.ts +++ b/src/pages/KeyValue/KeyValueVersions.ts @@ -10,11 +10,11 @@ export class KeyValueVersionsPage extends Page { constructor() { super(); } - goBack(): void { + async goBack(): Promise { if (pageState.currentSecretVersion != null) { pageState.currentSecretVersion = null; } - changePage("KEY_VALUE_SECRET"); + await changePage("KEY_VALUE_SECRET"); } async render(): Promise { setTitleElement(pageState); @@ -39,9 +39,9 @@ export class KeyValueVersionsPage extends Page { children: makeElement({ tag: "a", text: `v${ver}`, - onclick: () => { + onclick: async () => { pageState.currentSecretVersion = ver; - changePage("KEY_VALUE_SECRET"); + await changePage("KEY_VALUE_SECRET"); }, }), }), diff --git a/src/pages/KeyValue/KeyValueView.ts b/src/pages/KeyValue/KeyValueView.ts index 1c02489..ec93bc6 100644 --- a/src/pages/KeyValue/KeyValueView.ts +++ b/src/pages/KeyValue/KeyValueView.ts @@ -10,12 +10,12 @@ export class KeyValueViewPage extends Page { constructor() { super(); } - goBack(): void { + async goBack(): Promise { if (pageState.currentSecretPath.length != 0) { pageState.popCurrentSecretPath(); - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } else { - changePage("HOME"); + await changePage("HOME"); } } async render(): Promise { @@ -39,8 +39,8 @@ export class KeyValueViewPage extends Page { tag: "button", text: i18next.t("kv_view_new_btn"), class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], - onclick: () => { - changePage("KEY_VALUE_NEW_SECRET"); + onclick: async () => { + await changePage("KEY_VALUE_NEW_SECRET"); }, }); kvViewPageContent.appendChild(newButton); @@ -63,13 +63,13 @@ export class KeyValueViewPage extends Page { children: makeElement({ tag: "a", text: secret, - onclick: () => { + onclick: async () => { if (secret.endsWith("/")) { pageState.pushCurrentSecretPath(secret); - changePage("KEY_VALUE_VIEW"); + await changePage("KEY_VALUE_VIEW"); } else { pageState.currentSecret = secret; - changePage("KEY_VALUE_SECRET"); + await changePage("KEY_VALUE_SECRET"); } }, }), diff --git a/src/pages/Login.ts b/src/pages/Login.ts index 7fc44ab..5a6b4fa 100644 --- a/src/pages/Login.ts +++ b/src/pages/Login.ts @@ -12,7 +12,7 @@ export class LoginPage extends Page { constructor() { super(); } - render(): void { + async render(): Promise { const tokenLoginForm = makeElement({ tag: "form", children: [ @@ -139,7 +139,7 @@ export class LoginPage extends Page { pageState.token = token as string; lookupSelf() .then((_) => { - changePage("HOME"); + void changePage("HOME"); }) .catch((e: Error) => { document.getElementById("tokenInput").classList.add("uk-form-danger"); @@ -156,7 +156,7 @@ export class LoginPage extends Page { usernameLogin(formData.get("username") as string, formData.get("password") as string) .then((res) => { pageState.token = res; - changePage("HOME"); + void changePage("HOME"); }) .catch((e: Error) => { document.getElementById("usernameInput").classList.add("uk-form-danger"); diff --git a/src/pages/Me.ts b/src/pages/Me.ts index 748e2c9..b2dece8 100644 --- a/src/pages/Me.ts +++ b/src/pages/Me.ts @@ -31,9 +31,9 @@ export class MePage extends Page { children: makeElement({ tag: "a", text: i18next.t("log_out_btn"), - onclick: () => { + onclick: async () => { pageState.token = ""; - changePage("HOME"); + await changePage("HOME"); }, }), }), @@ -59,7 +59,7 @@ export class MePage extends Page { onclick: () => { renewSelf() .then(() => { - changePage("HOME"); + void changePage("HOME"); }) .catch((e: Error) => { setErrorText(e.message); @@ -82,7 +82,7 @@ export class MePage extends Page { text: i18next.t("seal_vault_btn"), onclick: async () => { await sealVault(); - changePage("UNSEAL_VAULT"); + await changePage("UNSEAL_VAULT"); }, }), }), @@ -91,8 +91,8 @@ export class MePage extends Page { children: makeElement({ tag: "a", text: i18next.t("change_language_btn"), - onclick: () => { - changePage("SET_LANGUAGE"); + onclick: async () => { + await changePage("SET_LANGUAGE"); }, }), }), diff --git a/src/pages/PwGen.ts b/src/pages/PwGen.ts index 80c63e5..a59b825 100644 --- a/src/pages/PwGen.ts +++ b/src/pages/PwGen.ts @@ -58,7 +58,7 @@ export class PwGenPage extends Page { passwordAlphabet: HTMLSelectElement; passwordForm: HTMLFormElement; - render(): void { + async render(): Promise { setPageContent(""); this.passwordBox = CopyableInputBox(genPassword(passwordOptionsDefault)); @@ -135,7 +135,7 @@ export class PwGenPage extends Page { ); } - cleanup(): void { + async cleanup(): Promise { this.passwordBox = undefined; this.passwordLengthTitle = undefined; this.passwordLengthRange = undefined; diff --git a/src/pages/SetLanguage.ts b/src/pages/SetLanguage.ts index fd10999..2686584 100644 --- a/src/pages/SetLanguage.ts +++ b/src/pages/SetLanguage.ts @@ -15,7 +15,7 @@ export class SetLanguagePage extends Page { constructor() { super(); } - render(): void { + async render(): Promise { const setLanguageForm = makeElement({ tag: "form", id: "setLanguageForm", @@ -61,7 +61,7 @@ export class SetLanguagePage extends Page { void i18next.changeLanguage(language).then((t) => { pageState.pageDirection = t("language_direction"); reloadNavBar(); - changePage("HOME"); + void changePage("HOME"); }); }); } diff --git a/src/pages/SetVaultURL.ts b/src/pages/SetVaultURL.ts index f03ca51..14dbaac 100644 --- a/src/pages/SetVaultURL.ts +++ b/src/pages/SetVaultURL.ts @@ -7,7 +7,7 @@ export class SetVaultURLPage extends Page { constructor() { super(); } - render(): void { + async render(): Promise { setPageContent( makeElement({ tag: "form", @@ -47,7 +47,7 @@ export class SetVaultURLPage extends Page { e.preventDefault(); const formData = new FormData(document.querySelector("#setVaultURLForm")); pageState.apiURL = formData.get("vaultURL") as string; - changePage("HOME"); + void changePage("HOME"); }); } get name(): string { diff --git a/src/pages/TOTP/NewTOTP.ts b/src/pages/TOTP/NewTOTP.ts index 1f783b3..2d8deb7 100644 --- a/src/pages/TOTP/NewTOTP.ts +++ b/src/pages/TOTP/NewTOTP.ts @@ -20,10 +20,10 @@ export class NewTOTPPage extends Page { constructor() { super(); } - goBack(): void { - changePage("TOTP"); + async goBack(): Promise { + await changePage("TOTP"); } - render(): void { + async render(): Promise { setTitleElement(pageState); const totpForm = makeElement({ @@ -97,7 +97,7 @@ export class NewTOTPPage extends Page { }; addNewTOTP(pageState.currentBaseMount, parms) .then((_) => { - changePage("TOTP"); + void changePage("TOTP"); }) .catch((e: Error) => { setErrorText(`API Error: ${e.message}`); diff --git a/src/pages/TOTP/TOTPView.ts b/src/pages/TOTP/TOTPView.ts index 29539b1..17b5a12 100644 --- a/src/pages/TOTP/TOTPView.ts +++ b/src/pages/TOTP/TOTPView.ts @@ -34,7 +34,7 @@ export class TOTPViewPage extends Page { tag: "a", text: i18next.t("totp_view_new_btn"), onclick: () => { - changePage("NEW_TOTP"); + void changePage("NEW_TOTP"); }, }), makeElement({ @@ -51,7 +51,8 @@ export class TOTPViewPage extends Page { try { const res = await getTOTPKeys(pageState.currentBaseMount); - for (const totpKeyName in res.entries()) { + for (const totpKeyName of res) { + console.log(totpKeyName); const totpListElement = this.makeTOTPListElement(totpKeyName); totpList.appendChild(totpListElement); this.totpListElements[totpKeyName] = totpListElement; @@ -81,7 +82,7 @@ export class TOTPViewPage extends Page { }, 3000) as unknown as number; } - cleanup(): void { + async cleanup(): Promise { clearInterval(this.refresher); this.totpListElements = {}; } diff --git a/src/pages/Transit/TransitDecrypt.ts b/src/pages/Transit/TransitDecrypt.ts index 0b33ec3..37abc1b 100644 --- a/src/pages/Transit/TransitDecrypt.ts +++ b/src/pages/Transit/TransitDecrypt.ts @@ -13,13 +13,13 @@ export class TransitDecryptPage extends Page { super(); } - goBack(): void { - changePage("TRANSIT_VIEW_SECRET"); + async goBack(): Promise { + await changePage("TRANSIT_VIEW_SECRET"); } transitDecryptForm: HTMLFormElement; - render(): void { + async render(): Promise { setTitleElement(pageState); setPageContent( makeElement({ diff --git a/src/pages/Transit/TransitEncrypt.ts b/src/pages/Transit/TransitEncrypt.ts index 2bbd413..574464f 100644 --- a/src/pages/Transit/TransitEncrypt.ts +++ b/src/pages/Transit/TransitEncrypt.ts @@ -13,13 +13,13 @@ export class TransitEncryptPage extends Page { super(); } - goBack(): void { - changePage("TRANSIT_VIEW_SECRET"); + async goBack(): Promise { + await changePage("TRANSIT_VIEW_SECRET"); } transitEncryptForm: HTMLFormElement; - render(): void { + async render(): Promise { setTitleElement(pageState); setPageContent( makeElement({ diff --git a/src/pages/Transit/TransitRewrap.ts b/src/pages/Transit/TransitRewrap.ts index ab90975..17f8a08 100644 --- a/src/pages/Transit/TransitRewrap.ts +++ b/src/pages/Transit/TransitRewrap.ts @@ -17,8 +17,8 @@ export class TransitRewrapPage extends Page { super(); } - goBack(): void { - changePage("TRANSIT_VIEW_SECRET"); + async goBack(): Promise { + await changePage("TRANSIT_VIEW_SECRET"); } transitRewrapForm: HTMLFormElement; diff --git a/src/pages/Transit/TransitView.ts b/src/pages/Transit/TransitView.ts index c9b86ed..60704be 100644 --- a/src/pages/Transit/TransitView.ts +++ b/src/pages/Transit/TransitView.ts @@ -11,8 +11,8 @@ export class TransitViewPage extends Page { super(); } - goBack(): void { - changePage("HOME"); + async goBack(): Promise { + await changePage("HOME"); } async render(): Promise { @@ -28,7 +28,7 @@ export class TransitViewPage extends Page { text: "New", class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], onclick: () => { - changePage("TRANSIT_NEW_KEY"); + void changePage("TRANSIT_NEW_KEY"); }, }); transitViewContent.appendChild(newButton); @@ -49,7 +49,7 @@ export class TransitViewPage extends Page { text: secret, onclick: () => { pageState.currentSecret = secret; - changePage("TRANSIT_VIEW_SECRET"); + void changePage("TRANSIT_VIEW_SECRET"); }, }), }); diff --git a/src/pages/Transit/TransitViewSecret.ts b/src/pages/Transit/TransitViewSecret.ts index e655655..5cf7ee2 100644 --- a/src/pages/Transit/TransitViewSecret.ts +++ b/src/pages/Transit/TransitViewSecret.ts @@ -11,8 +11,8 @@ export class TransitViewSecretPage extends Page { super(); } - goBack(): void { - changePage("TRANSIT_VIEW"); + async goBack(): Promise { + await changePage("TRANSIT_VIEW"); } async render(): Promise { @@ -33,7 +33,7 @@ export class TransitViewSecretPage extends Page { icon: "lock", iconText: i18next.t("transit_view_encrypt_icon_text"), onclick: () => { - changePage("TRANSIT_ENCRYPT"); + void changePage("TRANSIT_ENCRYPT"); }, }), Tile({ @@ -43,7 +43,7 @@ export class TransitViewSecretPage extends Page { icon: "mail", iconText: i18next.t("transit_view_decrypt_icon_text"), onclick: () => { - changePage("TRANSIT_DECRYPT"); + void changePage("TRANSIT_DECRYPT"); }, }), Tile({ @@ -53,7 +53,7 @@ export class TransitViewSecretPage extends Page { icon: "code", iconText: i18next.t("transit_view_rewrap_icon_text"), onclick: () => { - changePage("TRANSIT_REWRAP"); + void changePage("TRANSIT_REWRAP"); }, }), ], diff --git a/src/pages/Unseal.ts b/src/pages/Unseal.ts index 531fe8b..6ea4dbc 100644 --- a/src/pages/Unseal.ts +++ b/src/pages/Unseal.ts @@ -26,7 +26,7 @@ export class UnsealPage extends Page { unsealInputContent: HTMLElement; unsealKeyForm: HTMLFormElement; - cleanup(): void { + async cleanup(): Promise { this.deinitWebcam(); clearInterval(this.refresher); } @@ -169,7 +169,7 @@ export class UnsealPage extends Page { progressBar.max = keysNeeded; if (!data.sealed) { progressBar.value = keysNeeded; - changePage("HOME"); + void changePage("HOME"); } } diff --git a/src/playground.ts b/src/playground.ts index eb4568e..6d47103 100644 --- a/src/playground.ts +++ b/src/playground.ts @@ -15,7 +15,7 @@ declare global { } // Please empty this function before committing. -export function playground(): void { +export async function playground(): Promise { console.log("Welcome to Playground!"); window.pageState = pageState; window.i18next = i18next; diff --git a/src/types/Page.ts b/src/types/Page.ts index 3b8d6a5..79872eb 100644 --- a/src/types/Page.ts +++ b/src/types/Page.ts @@ -4,20 +4,17 @@ export class Page { constructor() { // Do Nothing } - render(): unknown { - // Do Nothing - return null; - } + async render(): Promise {} get name(): string { return "Page"; } get titleSuffix(): string { return ""; } - goBack(): void { - changePage("HOME"); + async goBack(): Promise { + await changePage("HOME"); } - cleanup(): void { + async cleanup(): Promise { // Do Nothing } }