mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-17 06:14:21 +01:00
check if already initialized more progress, zap feed not loading? request send receive fix setup profile editing and show zaps wallet connections kitchen sink mutiny plus and misc get rid of swap backup / restore, nostr stuff get rid of gifts channels stuff manage federations and profile fixes cleanup fix build fix chrome android update to cap 6 bump to actual 6.0.0 update xcode version fix interpolation again (regression) move all static methods to the worker add doc strings get rid of window.nostr, make parse params async fight load flicker use a "-test" bundle for debug builds so they don't clobber add back swaps and do some cleanup fix activity flicker
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { useNavigate } from "@solidjs/router";
|
|
import { SecureStoragePlugin } from "capacitor-secure-storage-plugin";
|
|
import { createSignal, Show } from "solid-js";
|
|
|
|
import { Button, InfoBox, SimpleInput } from "~/components";
|
|
import { useMegaStore } from "~/state/megaStore";
|
|
|
|
export function ImportNsecForm(props: { setup?: boolean }) {
|
|
const [_state, _actions, sw] = useMegaStore();
|
|
const navigate = useNavigate();
|
|
const [nsec, setNsec] = createSignal("");
|
|
const [saving, setSaving] = createSignal(false);
|
|
const [error, setError] = createSignal<string | undefined>();
|
|
|
|
async function saveNsec() {
|
|
setSaving(true);
|
|
setError(undefined);
|
|
const trimmedNsec = nsec().trim();
|
|
try {
|
|
const npub = await sw.nsec_to_npub(trimmedNsec);
|
|
if (!npub) {
|
|
throw new Error("Invalid nsec");
|
|
}
|
|
await SecureStoragePlugin.set({ key: "nsec", value: trimmedNsec });
|
|
|
|
const new_npub = await sw.change_nostr_keys(trimmedNsec, undefined);
|
|
console.log("Changed to new npub: ", new_npub);
|
|
if (props.setup) {
|
|
navigate("/addfederation");
|
|
} else {
|
|
navigate("/");
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
setError("Invalid nsec");
|
|
}
|
|
setSaving(false);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<SimpleInput
|
|
value={nsec()}
|
|
type="password"
|
|
onInput={(e) => setNsec(e.currentTarget.value)}
|
|
placeholder={`Nostr private key (starts with "nsec")`}
|
|
/>
|
|
<Button layout="full" onClick={saveNsec} loading={saving()}>
|
|
Import
|
|
</Button>
|
|
<Show when={error()}>
|
|
<InfoBox accent="red">{error()}</InfoBox>
|
|
</Show>
|
|
</>
|
|
);
|
|
}
|