diff --git a/src/components/Activity.tsx b/src/components/Activity.tsx index e25b944..2b3079e 100644 --- a/src/components/Activity.tsx +++ b/src/components/Activity.tsx @@ -1,7 +1,7 @@ import send from '~/assets/icons/send.svg'; import receive from '~/assets/icons/receive.svg'; -import { Card, Hr, LoadingSpinner, SmallAmount, SmallHeader, VStack } from './layout'; -import { For, JSX, Match, Show, Suspense, Switch, createMemo, createResource, createSignal } from 'solid-js'; +import { Card, LoadingSpinner, SmallAmount, SmallHeader, VStack } from './layout'; +import { For, Match, ParentComponent, Suspense, Switch, createMemo, createResource, createSignal } from 'solid-js'; import { useMegaStore } from '~/state/megaStore'; import { MutinyInvoice } from '@mutinywallet/mutiny-wasm'; import { prettyPrintTime } from '~/utils/prettyPrintTime'; @@ -34,7 +34,7 @@ type Utxo = { is_spent: boolean } -function SubtleText(props: { children: any }) { +const SubtleText: ParentComponent = (props) => { return

{props.children}

} @@ -50,7 +50,7 @@ function OnChainItem(props: { item: OnChainTx }) { Mempool Link -
setOpen(!open())}> +
setOpen(!open())}> {isReceive() ? receive arrow : send arrow}

Label Missing

@@ -76,7 +76,7 @@ function InvoiceItem(props: { item: MutinyInvoice }) { return ( <> -
setOpen(!open())}> +
setOpen(!open())}> {isSend() ? send arrow : receive arrow}

Label Missing

@@ -101,7 +101,7 @@ function Utxo(props: { item: Utxo }) { return ( <> -
setOpen(!open())}> +
setOpen(!open())}> receive arrow

Label Missing

@@ -138,9 +138,9 @@ export function Activity() { return utxos; } - const [transactions, { refetch: refetchTransactions }] = createResource(getTransactions); - const [invoices, { refetch: refetchInvoices }] = createResource(getInvoices); - const [utxos, { refetch: refetchUtxos }] = createResource(getUtXos); + const [transactions, { refetch: _refetchTransactions }] = createResource(getTransactions); + const [invoices, { refetch: _refetchInvoices }] = createResource(getInvoices); + const [utxos, { refetch: _refetchUtxos }] = createResource(getUtXos); return ( diff --git a/src/components/Amount.tsx b/src/components/Amount.tsx index 0705368..f869b67 100644 --- a/src/components/Amount.tsx +++ b/src/components/Amount.tsx @@ -1,4 +1,4 @@ -import { Show, createResource } from "solid-js" +import { Show } from "solid-js" import { useMegaStore } from "~/state/megaStore" import { satsToUsd } from "~/utils/conversions" diff --git a/src/components/AmountEditable.tsx b/src/components/AmountEditable.tsx index c467a46..7f39aa4 100644 --- a/src/components/AmountEditable.tsx +++ b/src/components/AmountEditable.tsx @@ -1,4 +1,4 @@ -import { For, createMemo, createResource, createSignal } from 'solid-js'; +import { For, createMemo, createSignal } from 'solid-js'; import { Button } from '~/components/layout'; import { useMegaStore } from '~/state/megaStore'; import { satsToUsd } from '~/utils/conversions'; diff --git a/src/components/DeleteEverything.tsx b/src/components/DeleteEverything.tsx new file mode 100644 index 0000000..15bc623 --- /dev/null +++ b/src/components/DeleteEverything.tsx @@ -0,0 +1,50 @@ +import { createSignal } from "solid-js"; +import { ConfirmDialog } from "~/components/Dialog"; +import { Button } from "~/components/layout"; +import { showToast } from "~/components/Toaster"; + +export function deleteDb(name: string) { + const req = indexedDB.deleteDatabase(name); + req.onsuccess = function () { + console.log("Deleted database successfully"); + showToast({ title: "Deleted", description: `Deleted "${name}" database successfully` }) + }; + req.onerror = function () { + console.error("Couldn't delete database"); + showToast(new Error("Couldn't delete database")) + }; + req.onblocked = function () { + console.error("Couldn't delete database due to the operation being blocked"); + showToast(new Error("Couldn't delete database due to the operation being blocked")) + }; +} + +export function DeleteEverything() { + async function resetNode() { + setConfirmLoading(true); + deleteDb("gossip") + localStorage.clear(); + showToast({ title: "Deleted", description: `Deleted all data` }) + setConfirmOpen(false); + setConfirmLoading(false); + setTimeout(() => { + window.location.reload(); + }, 1000); + } + + async function confirmReset() { + setConfirmOpen(true); + } + + const [confirmOpen, setConfirmOpen] = createSignal(false); + const [confirmLoading, setConfirmLoading] = createSignal(false); + + return ( + <> + + setConfirmOpen(false)}> + This will delete your node's state. This can't be undone! + + + ) +} \ No newline at end of file diff --git a/src/components/KitchenSink.tsx b/src/components/KitchenSink.tsx index fab52bb..1fe29ac 100644 --- a/src/components/KitchenSink.tsx +++ b/src/components/KitchenSink.tsx @@ -3,11 +3,11 @@ import { Card, Hr, SmallHeader, Button, InnerCard, VStack } from "~/components/l import PeerConnectModal from "~/components/PeerConnectModal"; import { For, Show, Suspense, createEffect, createResource, createSignal, onCleanup } from "solid-js"; import { MutinyChannel, MutinyPeer } from "@mutinywallet/mutiny-wasm"; -import { Collapsible, TextField, toaster } from "@kobalte/core"; +import { Collapsible, TextField } from "@kobalte/core"; import mempoolTxUrl from "~/utils/mempoolTxUrl"; import eify from "~/utils/eify"; import { ConfirmDialog } from "./Dialog"; -import { ToastItem, showToast } from "./Toaster"; +import { showToast } from "./Toaster"; // TODO: hopefully I don't have to maintain this type forever but I don't know how to pass it around otherwise type RefetchPeersType = (info?: unknown) => MutinyPeer[] | Promise | null | undefined diff --git a/src/components/SeedWords.tsx b/src/components/SeedWords.tsx new file mode 100644 index 0000000..8c70b43 --- /dev/null +++ b/src/components/SeedWords.tsx @@ -0,0 +1,27 @@ +import { Match, Switch, createSignal } from "solid-js" + +export function SeedWords(props: { words: string }) { + const [shouldShow, setShouldShow] = createSignal(false) + + function toggleShow() { + setShouldShow(!shouldShow()) + } + + return (
+        
+            
+                
+ TAP TO REVEAL SEED WORDS +
+
+ + +
+

+ {props.words} +

+
+
+
+
) +} \ No newline at end of file diff --git a/src/components/SettingsStringsEditor.tsx b/src/components/SettingsStringsEditor.tsx index 11c19b4..c201200 100644 --- a/src/components/SettingsStringsEditor.tsx +++ b/src/components/SettingsStringsEditor.tsx @@ -3,7 +3,7 @@ import { TextField } from '~/components/layout/TextField'; import { NodeManagerSettingStrings, getExistingSettings } from '~/logic/nodeManagerSetup'; import { Button } from '~/components/layout'; import { createSignal } from 'solid-js'; -import { deleteDb } from '~/routes/Settings'; +import { deleteDb } from '~/components/DeleteEverything'; import { showToast } from './Toaster'; import eify from '~/utils/eify'; import { ConfirmDialog } from "~/components/Dialog"; @@ -11,12 +11,12 @@ import { useMegaStore } from '~/state/megaStore'; export function SettingsStringsEditor() { const existingSettings = getExistingSettings(); - const [settingsForm, { Form, Field, FieldArray }] = createForm({ initialValues: existingSettings }); + const [_settingsForm, { Form, Field }] = createForm({ initialValues: existingSettings }); const [confirmOpen, setConfirmOpen] = createSignal(false); const [settingsTemp, setSettingsTemp] = createSignal(); - const [state, actions] = useMegaStore(); + const [_store, actions] = useMegaStore(); async function handleSubmit(values: NodeManagerSettingStrings) { try { @@ -56,7 +56,10 @@ export function SettingsStringsEditor() { } return
- setConfirmOpen(false)} /> + 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 diff --git a/src/components/layout/Button.tsx b/src/components/layout/Button.tsx index 5030215..32744c5 100644 --- a/src/components/layout/Button.tsx +++ b/src/components/layout/Button.tsx @@ -1,5 +1,5 @@ import { cva, VariantProps } from "class-variance-authority"; -import { children, JSX, ParentComponent, Show, splitProps, Switch } from "solid-js"; +import { children, JSX, ParentComponent, Show, splitProps } from "solid-js"; import { Dynamic } from "solid-js/web"; import { A } from "solid-start"; import { LoadingSpinner } from "."; diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx index 0e356f7..2b38535 100644 --- a/src/components/layout/index.tsx +++ b/src/components/layout/index.tsx @@ -92,8 +92,8 @@ const LargeHeader: ParentComponent = (props) => { return (

{props.children}

) } -const VStack: ParentComponent = (props) => { - return (
{props.children}
) +const VStack: ParentComponent<{ biggap?: boolean }> = (props) => { + return (
{props.children}
) } const SmallAmount: ParentComponent<{ amount: number | bigint }> = (props) => { diff --git a/src/components/waitlist/WaitlistForm.tsx b/src/components/waitlist/WaitlistForm.tsx index 255701f..c6f184e 100644 --- a/src/components/waitlist/WaitlistForm.tsx +++ b/src/components/waitlist/WaitlistForm.tsx @@ -73,7 +73,7 @@ export default function WaitlistForm() { - {(field, props) => ( + {(field, _props) => ( // TODO: there's probably a "real" way to do this with modular-forms setValue(waitlistForm, "user_type", newValue as "nostr" | "email")} choices={COMMUNICATION_METHODS} /> )} diff --git a/src/routes/Admin.tsx b/src/routes/Admin.tsx index d92dff0..51404b2 100644 --- a/src/routes/Admin.tsx +++ b/src/routes/Admin.tsx @@ -1,18 +1,25 @@ +import { DeleteEverything } from "~/components/DeleteEverything"; import KitchenSink from "~/components/KitchenSink"; import NavBar from "~/components/NavBar"; -import { Card, DefaultMain, LargeHeader, SafeArea, VStack } from "~/components/layout"; +import { Card, DefaultMain, LargeHeader, NodeManagerGuard, SafeArea, SmallHeader, VStack } from "~/components/layout"; export default function Admin() { return ( - - - Admin - -

If you know what you're doing you're in the right place!

- -
-
- -
+ + + + Admin + +

If you know what you're doing you're in the right place!

+ +
+ Danger zone + +
+
+
+ +
+
) } \ No newline at end of file diff --git a/src/routes/Scanner.tsx b/src/routes/Scanner.tsx index 359e365..b03e331 100644 --- a/src/routes/Scanner.tsx +++ b/src/routes/Scanner.tsx @@ -1,7 +1,7 @@ import Reader from "~/components/Reader"; import { createEffect, createSignal, Show } from "solid-js"; import { useNavigate } from "solid-start"; -import { Button, SafeArea } from "~/components/layout"; +import { Button } from "~/components/layout"; export default function Scanner() { const [scanResult, setScanResult] = createSignal(); diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index 7e106c1..3676d44 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -1,66 +1,28 @@ -import { createSignal } from "solid-js"; -import { useNavigate } from "solid-start"; -import { ConfirmDialog } from "~/components/Dialog"; -import KitchenSink from "~/components/KitchenSink"; -import { Button, Card, DefaultMain, Hr, LargeHeader, SafeArea } from "~/components/layout"; +import { ButtonLink, DefaultMain, LargeHeader, NodeManagerGuard, SafeArea, VStack } from "~/components/layout"; import NavBar from "~/components/NavBar"; +import { SeedWords } from "~/components/SeedWords"; import { SettingsStringsEditor } from "~/components/SettingsStringsEditor"; -import { showToast } from "~/components/Toaster"; import { useMegaStore } from "~/state/megaStore"; -export function deleteDb(name: string) { - const req = indexedDB.deleteDatabase(name); - req.onsuccess = function () { - console.log("Deleted database successfully"); - showToast({ title: "Deleted", description: `Deleted "${name}" database successfully` }) - }; - req.onerror = function () { - console.error("Couldn't delete database"); - showToast(new Error("Couldn't delete database")) - }; - req.onblocked = function () { - console.error("Couldn't delete database due to the operation being blocked"); - showToast(new Error("Couldn't delete database due to the operation being blocked")) - }; -} - export default function Settings() { - const navigate = useNavigate(); - - const [_, actions] = useMegaStore(); - - async function resetNode() { - setConfirmLoading(true); - deleteDb("gossip") - localStorage.clear(); - showToast({ title: "Deleted", description: `Deleted all data` }) - setConfirmOpen(false); - setConfirmLoading(false); - setTimeout(() => { - window.location.reload(); - }, 1000); - } - - async function confirmReset() { - setConfirmOpen(true); - } - - const [confirmOpen, setConfirmOpen] = createSignal(false); - const [confirmLoading, setConfirmLoading] = createSignal(false); + const [store, _actions] = useMegaStore(); return ( - - - Settings - - - {/* */} - {/* */} - - setConfirmOpen(false)} /> - - - - + + + + Settings + + +

Write down these words or you'll die!

+ +
+ + "I know what I'm doing" +
+
+ +
+
) } \ No newline at end of file diff --git a/src/utils/prettyPrintTime.ts b/src/utils/prettyPrintTime.ts index 3b827b5..254c2db 100644 --- a/src/utils/prettyPrintTime.ts +++ b/src/utils/prettyPrintTime.ts @@ -1,5 +1,5 @@ export function prettyPrintTime(ts: number) { - const options = { + const options: Intl.DateTimeFormatOptions = { weekday: 'long', year: 'numeric', month: 'short', @@ -8,5 +8,5 @@ export function prettyPrintTime(ts: number) { minute: 'numeric' }; - return new Date(ts * 1000).toLocaleString('en-US', options as any); + return new Date(ts * 1000).toLocaleString('en-US', options); } \ No newline at end of file