import { Show, createSignal } from "solid-js"; import { Button, SimpleDialog, TextField, InfoBox } from "~/components"; import { useMegaStore } from "~/state/megaStore"; import eify from "~/utils/eify"; import { A } from "solid-start"; import { useI18n } from "~/i18n/context"; export function DecryptDialog() { const i18n = useI18n(); const [state, actions] = useMegaStore(); const [password, setPassword] = createSignal(""); const [loading, setLoading] = createSignal(false); const [error, setError] = createSignal(""); async function decrypt(e: Event) { e.preventDefault(); setLoading(true); try { await actions.setup(password()); // If we get this far and the state stills wants a password that means the password was wrong if (state.needs_password) { throw new Error("wrong"); } } catch (e) { const err = eify(e); console.error(e); if (err.message === "wrong") { setError(i18n.t("settings.decrypt.error_wrong_password")); } else { throw e; } } finally { setLoading(false); } } function noop() { // noop } return (
setPassword(e.currentTarget.value)} error={""} onBlur={noop} onChange={noop} /> {error()}
{i18n.t("settings.decrypt.forgot_password_link")}
); }