add settings page with reset app: clears keychain secrets and SQLite cache
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
import ArrowDown from '@lucide/svelte/icons/arrow-down'
|
||||
import ArrowUp from '@lucide/svelte/icons/arrow-up'
|
||||
import QrCodeIcon from '@lucide/svelte/icons/qr-code'
|
||||
import SettingsIcon from '@lucide/svelte/icons/settings'
|
||||
import Fingerprint from '@lucide/svelte/icons/fingerprint'
|
||||
import * as Dialog from '$lib/components/ui/dialog/index.js'
|
||||
import QRCode from 'qrcode'
|
||||
@@ -252,6 +253,9 @@
|
||||
<Button onclick={() => w.refresh()} disabled={w.loading}>
|
||||
{w.loading ? 'Refreshing...' : 'Refresh'}
|
||||
</Button>
|
||||
<Button variant="outline" onclick={() => navigate('/settings')}>
|
||||
<SettingsIcon size={16} />
|
||||
</Button>
|
||||
<Button variant="outline" onclick={() => w.lock()}>
|
||||
Lock
|
||||
</Button>
|
||||
|
||||
@@ -92,6 +92,10 @@ export type TokenBalanceResult = {
|
||||
type RPC = {
|
||||
bun: {
|
||||
requests: {
|
||||
resetApp: {
|
||||
params: {}
|
||||
response: boolean
|
||||
}
|
||||
biometricCanAuth: {
|
||||
params: {}
|
||||
response: boolean
|
||||
|
||||
@@ -199,6 +199,24 @@ export const Wallet = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const resetApp = async () => {
|
||||
if (!electrobun.rpc) return false
|
||||
const [ok] = await tryCatch(
|
||||
electrobun.rpc.request.resetApp({}),
|
||||
)
|
||||
if (!ok) return false
|
||||
seed = ''
|
||||
address = ''
|
||||
balance = '0'
|
||||
error = ''
|
||||
tokenBalances = []
|
||||
transactions = []
|
||||
apiKey = ''
|
||||
vaultExists = false
|
||||
passwordHash = ''
|
||||
return true
|
||||
}
|
||||
|
||||
const setPassword = async (password: string) => {
|
||||
if (!electrobun.rpc) return
|
||||
const ph = await hashPassword(password)
|
||||
@@ -473,6 +491,7 @@ export const Wallet = () => {
|
||||
unlockWithBiometrics,
|
||||
unlockWithPassword,
|
||||
setPassword,
|
||||
resetApp,
|
||||
saveVault,
|
||||
switchNetwork,
|
||||
saveApiKey,
|
||||
|
||||
Reference in New Issue
Block a user