0.0.2 loading states + wallet dialogs + monero unlock flow
This commit is contained in:
@@ -19,8 +19,27 @@
|
||||
let moneroMnemonic = $state('')
|
||||
let moneroRestoreHeight = $state<number | undefined>(undefined)
|
||||
|
||||
let walletPassword = $state('')
|
||||
let rememberPassword = $state(true)
|
||||
let unlocking = $state(false)
|
||||
let unlockError = $state('')
|
||||
|
||||
let initStarted = false
|
||||
|
||||
async function unlockWithPassword() {
|
||||
if (unlocking || !walletPassword.trim()) return
|
||||
unlocking = true
|
||||
unlockError = ''
|
||||
try {
|
||||
await w.unlockWallet(walletPassword.trim(), rememberPassword)
|
||||
walletPassword = ''
|
||||
} catch (e) {
|
||||
unlockError = e instanceof Error ? e.message : 'Failed to unlock wallet'
|
||||
} finally {
|
||||
unlocking = false
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (w.walletOpen && w.walletName) {
|
||||
navigate('/monero/wallet/:name', {
|
||||
@@ -40,7 +59,7 @@
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
if (w.running && !w.walletOpen && w.wallets.length > 0 && !w.loading) {
|
||||
if (w.running && !w.walletOpen && w.wallets.length > 0 && !w.loading && !w.opening) {
|
||||
w.autoUnlock(w.wallets[0])
|
||||
}
|
||||
})
|
||||
@@ -66,6 +85,15 @@
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{:else if w.opening}
|
||||
<Card>
|
||||
<CardContent class="flex items-center justify-center gap-2 py-8">
|
||||
<Loader />
|
||||
<span class="text-sm text-muted-foreground">
|
||||
{!w.running ? 'Starting wallet server...' : 'Opening wallet...'}
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{:else if !w.installed}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
@@ -99,7 +127,48 @@
|
||||
</CardContent>
|
||||
</Card>
|
||||
{:else if !w.walletOpen}
|
||||
{#if w.wallets.length > 0}
|
||||
{#if w.opening}
|
||||
<Card>
|
||||
<CardContent class="flex items-center justify-center py-8">
|
||||
<Loader />
|
||||
<span class="ml-2 text-sm text-muted-foreground">
|
||||
Opening wallet...
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{:else if w.passwordRequired && w.wallets.length > 0}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Wallet locked</CardTitle>
|
||||
<CardDescription>
|
||||
Enter the password for {w.wallets[0]} to open it
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Input
|
||||
type="password"
|
||||
placeholder="Wallet password"
|
||||
bind:value={walletPassword} />
|
||||
<label class="flex items-center gap-2 text-xs">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={rememberPassword}
|
||||
class="h-3.5 w-3.5" />
|
||||
Remember password for auto-unlock
|
||||
</label>
|
||||
<Button
|
||||
onclick={unlockWithPassword}
|
||||
disabled={unlocking || !walletPassword.trim()}>
|
||||
{unlocking ? 'Opening...' : 'Unlock Wallet'}
|
||||
</Button>
|
||||
{#if unlockError}
|
||||
<p class="text-xs text-destructive">{unlockError}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{:else if w.wallets.length > 0}
|
||||
<Card>
|
||||
<CardContent class="flex items-center justify-center py-8">
|
||||
<Loader />
|
||||
|
||||
Reference in New Issue
Block a user