Skip to content

Commit

Permalink
Remove no longer needed password handling for reading logs
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Feb 13, 2024
1 parent d91dd27 commit 58dc4a8
Showing 1 changed file with 3 additions and 56 deletions.
59 changes: 3 additions & 56 deletions src/components/Logs.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { MutinyWallet } from "@mutinywallet/mutiny-wasm";
import { createSignal, Show } from "solid-js";

import {
Button,
InfoBox,
InnerCard,
NiceP,
SimpleDialog,
TextField,
VStack
} from "~/components";
import { Button, InfoBox, InnerCard, NiceP, VStack } from "~/components";
import { useI18n } from "~/i18n/context";
import { downloadTextFile, eify } from "~/utils";

Expand All @@ -18,40 +10,22 @@ export function Logs() {

// Create state for errors, password and dialog visibility
const [error, setError] = createSignal<Error>();
const [exportDecrypt, setExportDecrypt] = createSignal(false);
const [password, setPassword] = createSignal<string>();

async function handleSave() {
try {
setError(undefined);
const logs = await MutinyWallet.get_logs(password()); // Use password if required
const logs = await MutinyWallet.get_logs();
await downloadTextFile(
logs.join("") || "",
"mutiny-logs.txt",
"text/plain"
);
} catch (e) {
console.error(e);
const err = eify(e);
if (err.message === "Incorrect password entered.") {
setExportDecrypt(true);
} else {
setError(err);
}
setError(eify(e));
}
}

function savePassword(e: Event) {
e.preventDefault();
handleSave();
setPassword(undefined); // clear password after use
setExportDecrypt(false); // close the dialog
}

function noop() {
// noop
}

return (
<InnerCard title={i18n.t("settings.emergency_kit.logs.title")}>
<VStack>
Expand All @@ -65,33 +39,6 @@ export function Logs() {
<Show when={error()}>
<InfoBox accent="red">{error()?.message}</InfoBox>
</Show>
<SimpleDialog
title={i18n.t("settings.emergency_kit.logs.password")}
open={exportDecrypt()}
>
<form onSubmit={savePassword}>
<div class="flex flex-col gap-4">
<TextField
name="password"
type="password"
ref={noop}
value={password()}
onInput={(e) => setPassword(e.currentTarget.value)}
error={""}
onBlur={noop}
onChange={noop}
/>
<Show when={error()}>
<InfoBox accent="red">{error()?.message}</InfoBox>
</Show>
<Button intent="blue" onClick={savePassword}>
{i18n.t(
"settings.emergency_kit.logs.confirm_password_label"
)}
</Button>
</div>
</form>
</SimpleDialog>
</InnerCard>
);
}

0 comments on commit 58dc4a8

Please sign in to comment.