diff --git a/src/components/DeleteEverything.tsx b/src/components/DeleteEverything.tsx index 7262823..86d878c 100644 --- a/src/components/DeleteEverything.tsx +++ b/src/components/DeleteEverything.tsx @@ -2,6 +2,8 @@ import { createSignal } from "solid-js"; import { ConfirmDialog } from "~/components/Dialog"; import { Button } from "~/components/layout"; import { showToast } from "~/components/Toaster"; +import { useMegaStore } from "~/state/megaStore"; +import eify from "~/utils/eify"; export function deleteDb(name: string) { const req = indexedDB.deleteDatabase(name); @@ -20,17 +22,28 @@ export function deleteDb(name: string) { } export function DeleteEverything() { + const [_store, actions] = useMegaStore(); + async function resetNode() { - setConfirmLoading(true); - deleteDb("gossip") - deleteDb("wallet") - localStorage.clear(); - showToast({ title: "Deleted", description: `Deleted all data` }) - setConfirmOpen(false); - setConfirmLoading(false); - setTimeout(() => { - window.location.href = "/"; - }, 3000); + try { + setConfirmLoading(true); + deleteDb("gossip") + deleteDb("wallet") + localStorage.clear(); + + showToast({ title: "Deleted", description: `Deleted all data` }) + + setTimeout(() => { + window.location.href = "/"; + }, 3000); + } catch (e) { + console.error(e) + showToast(eify(e)) + } finally { + setConfirmOpen(false); + setConfirmLoading(false); + } + } async function confirmReset() { diff --git a/src/components/SettingsStringsEditor.tsx b/src/components/SettingsStringsEditor.tsx index 0fd6c13..ed31dcb 100644 --- a/src/components/SettingsStringsEditor.tsx +++ b/src/components/SettingsStringsEditor.tsx @@ -1,36 +1,22 @@ import { createForm, url } from '@modular-forms/solid'; import { TextField } from '~/components/layout/TextField'; import { MutinyWalletSettingStrings, getExistingSettings } from '~/logic/mutinyWalletSetup'; -import { Button } from '~/components/layout'; -import { createSignal } from 'solid-js'; -import { deleteDb } from '~/components/DeleteEverything'; +import { Button, SmallHeader } from '~/components/layout'; import { showToast } from './Toaster'; import eify from '~/utils/eify'; -import { ConfirmDialog } from "~/components/Dialog"; import { useMegaStore } from '~/state/megaStore'; export function SettingsStringsEditor() { const existingSettings = getExistingSettings(); const [_settingsForm, { Form, Field }] = createForm({ initialValues: existingSettings }); - const [confirmOpen, setConfirmOpen] = createSignal(false); - - const [settingsTemp, setSettingsTemp] = createSignal(); - const [_store, actions] = useMegaStore(); async function handleSubmit(values: MutinyWalletSettingStrings) { try { const existing = getExistingSettings(); const newSettings = { ...existing, ...values } - if (existing.network !== values.network) { - // If the network changes we need to confirm the wipe - // Save the settings so we can get them later - setSettingsTemp(newSettings); - setConfirmOpen(true); - } else { - await actions.setupMutinyWallet(newSettings); - window.location.reload(); - } + await actions.setupMutinyWallet(newSettings); + window.location.reload(); } catch (e) { console.error(e) showToast(eify(e)) @@ -38,42 +24,15 @@ export function SettingsStringsEditor() { console.log(values) } - async function confirmStateReset() { - try { - deleteDb("gossip") - localStorage.clear(); - showToast({ title: "Deleted", description: `Deleted all data` }) - const loadedValues = settingsTemp(); - - await actions.setupMutinyWallet(loadedValues); - window.location.reload(); - } catch (e) { - console.error(e) - showToast(eify(e)) - } - - setConfirmOpen(false); - } - return
- setConfirmOpen(false)}> - Are you sure? Changing networks will delete your node's state. This can't be undone! -

Don't trust us! Use your own servers to back Mutiny.

- - {(field, props) => ( - // TODO: make a cool select component -
- - -
- )} -
+
+ Network +
+                {existingSettings.network}
+            
+
+ {(field, props) => (