diff --git a/src/components/DeleteEverything.tsx b/src/components/DeleteEverything.tsx index 135e504..2a90794 100644 --- a/src/components/DeleteEverything.tsx +++ b/src/components/DeleteEverything.tsx @@ -1,3 +1,4 @@ +import initMutinyWallet, { MutinyWallet } from "@mutinywallet/mutiny-wasm"; import { createSignal } from "solid-js"; import { ConfirmDialog } from "~/components/Dialog"; import { Button } from "~/components/layout"; @@ -5,8 +6,8 @@ import { showToast } from "~/components/Toaster"; import { useMegaStore } from "~/state/megaStore"; import eify from "~/utils/eify"; -export function DeleteEverything() { - const [_state, actions] = useMegaStore(); +export function DeleteEverything(props: { emergency?: boolean }) { + const [state, actions] = useMegaStore(); async function confirmReset() { setConfirmOpen(true); @@ -18,7 +19,21 @@ export function DeleteEverything() { async function resetNode() { try { setConfirmLoading(true); - await actions.deleteMutinyWallet(); + // If we're in a context where the wallet is loaded we want to use the regular action to delete it + // Otherwise we just call the import_json method directly + if (state.mutiny_wallet && !props.emergency) { + try { + await actions.deleteMutinyWallet(); + } catch (e) { + // If we can't stop we want to keep going + console.error(e); + } + } else { + // If there's no mutiny_wallet loaded we might need to initialize WASM + await initMutinyWallet(); + await MutinyWallet.import_json("{}"); + } + showToast({ title: "Deleted", description: `Deleted all data` }); setTimeout(() => { diff --git a/src/components/ErrorDisplay.tsx b/src/components/ErrorDisplay.tsx index 8c76195..70234fe 100644 --- a/src/components/ErrorDisplay.tsx +++ b/src/components/ErrorDisplay.tsx @@ -1,11 +1,13 @@ -import { Title } from "solid-start"; +import { A, Title } from "solid-start"; import { Button, DefaultMain, LargeHeader, + NiceP, SafeArea, SmallHeader } from "~/components/layout"; +import { ExternalLink } from "./layout/ExternalLink"; export default function ErrorDisplay(props: { error: Error }) { return ( @@ -18,6 +20,17 @@ export default function ErrorDisplay(props: { error: Error }) { {props.error.name}:{" "} {props.error.message}

+ + Try reloading this page or clicking the "Dangit" button. If + you keep having problems,{" "} + + reach out to us for support. + + + + Getting desperate? Try the{" "} + emergency kit. +