1
0
Fork 0

Run linter.

This commit is contained in:
Kitteh 2021-05-22 13:54:30 +01:00
parent 331d8c9e81
commit a7acb3bd23

View file

@ -1,3 +1,4 @@
import { Component, JSX, render } from "preact";
import { CopyableInputBox } from "../../../elements/ReactCopyableInputBox"; import { CopyableInputBox } from "../../../elements/ReactCopyableInputBox";
import { DoesNotExistError } from "../../../types/internalErrors"; import { DoesNotExistError } from "../../../types/internalErrors";
import { Page } from "../../../types/Page"; import { Page } from "../../../types/Page";
@ -6,11 +7,11 @@ import { getTOTPCode } from "../../../api/totp/getTOTPCode";
import { getTOTPKeys } from "../../../api/totp/getTOTPKeys"; import { getTOTPKeys } from "../../../api/totp/getTOTPKeys";
import { setErrorText } from "../../../pageUtils"; import { setErrorText } from "../../../pageUtils";
import i18next from "i18next"; import i18next from "i18next";
import { render, JSX, Component } from "preact";
export class RefreshingTOTPGridItem extends Component<
{ baseMount: string; totpKey: string },
export class RefreshingTOTPGridItem extends Component<{ baseMount: string; totpKey: string }, { totpValue: string }> { { totpValue: string }
> {
constructor() { constructor() {
super(); super();
this.state = { totpValue: "" }; this.state = { totpValue: "" };
@ -18,9 +19,9 @@ export class RefreshingTOTPGridItem extends Component<{ baseMount: string; totpK
timer: unknown; timer: unknown;
updateTOTPCode(): void { updateTOTPCode(): void {
getTOTPCode(this.props.baseMount, this.props.totpKey).then((code) => { void getTOTPCode(this.props.baseMount, this.props.totpKey).then((code) => {
this.setState({ totpValue: code }); this.setState({ totpValue: code });
}) });
} }
componentDidMount(): void { componentDidMount(): void {
@ -53,43 +54,43 @@ export class TOTPViewPage extends Page {
} }
async render(): Promise<void> { async render(): Promise<void> {
render(( render(
<div> <div>
<button <button
class="uk-button uk-button-primary uk-margin-bottom" class="uk-button uk-button-primary uk-margin-bottom"
onClick={async () => { onClick={async () => {
await this.router.changePage("NEW_TOTP"); await this.router.changePage("NEW_TOTP");
}}> }}
>
{i18next.t("totp_view_new_btn")} {i18next.t("totp_view_new_btn")}
</button> </button>
<br /> <br />
<br /> <br />
<div id="totpList"> <div id="totpList">
{await (async () => { {
await (async () => {
try { try {
const elem = await Promise.all(Array.from(await getTOTPKeys(this.state.baseMount)).map(async (key) => const elem = await Promise.all(
<RefreshingTOTPGridItem Array.from(await getTOTPKeys(this.state.baseMount)).map(async (key) => (
baseMount={this.state.baseMount} <RefreshingTOTPGridItem baseMount={this.state.baseMount} totpKey={key} />
totpKey={key} )),
/> );
))
return elem; return elem;
} catch (e: unknown) { } catch (e: unknown) {
const error = e as Error; const error = e as Error;
if (error == DoesNotExistError) { if (error == DoesNotExistError) {
return <p>{i18next.t("totp_view_empty")}</p> return <p>{i18next.t("totp_view_empty")}</p>;
} else { } else {
setErrorText(error.message); setErrorText(error.message);
} }
} }
})()} })()
</div> }
</div> </div>
), this.router.pageContentElement) </div>,
this.router.pageContentElement,
);
} }
async getPageTitle(): Promise<Element | string> { async getPageTitle(): Promise<Element | string> {
return await SecretTitleElement(this.router); return await SecretTitleElement(this.router);