Add logging to attach & detach
This commit is contained in:
parent
71c753810c
commit
0957cb5b83
|
@ -59,13 +59,36 @@ export function useWallet (name) {
|
||||||
logger.ok('wallet disabled')
|
logger.ok('wallet disabled')
|
||||||
}, [name, me, logger])
|
}, [name, me, logger])
|
||||||
|
|
||||||
|
const save = useCallback((values) => {
|
||||||
|
try {
|
||||||
|
saveConfig(values)
|
||||||
|
logger.ok('wallet attached')
|
||||||
|
} catch (err) {
|
||||||
|
const message = 'failed to attach: ' + err.message || err.toString?.()
|
||||||
|
logger.error(message)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}, [saveConfig, logger])
|
||||||
|
|
||||||
|
// delete is a reserved keyword
|
||||||
|
const delete_ = useCallback(() => {
|
||||||
|
try {
|
||||||
|
clearConfig()
|
||||||
|
logger.ok('wallet detached')
|
||||||
|
} catch (err) {
|
||||||
|
const message = 'failed to detach: ' + err.message || err.toString?.()
|
||||||
|
logger.error(message)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}, [clearConfig, logger])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...wallet,
|
...wallet,
|
||||||
sendPayment,
|
sendPayment,
|
||||||
validate,
|
validate,
|
||||||
config,
|
config,
|
||||||
saveConfig,
|
save,
|
||||||
clearConfig,
|
delete: delete_,
|
||||||
enable,
|
enable,
|
||||||
disable,
|
disable,
|
||||||
isConfigured: !!config,
|
isConfigured: !!config,
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default function WalletSettings () {
|
||||||
try {
|
try {
|
||||||
const newConfig = !wallet.isConfigured
|
const newConfig = !wallet.isConfigured
|
||||||
await wallet.validate(values)
|
await wallet.validate(values)
|
||||||
wallet.saveConfig(values)
|
wallet.save(values)
|
||||||
// enable wallet if checkbox was set or if wallet was just configured
|
// enable wallet if checkbox was set or if wallet was just configured
|
||||||
if (enabled || newConfig) wallet.enable()
|
if (enabled || newConfig) wallet.enable()
|
||||||
else wallet.disable()
|
else wallet.disable()
|
||||||
|
@ -61,13 +61,12 @@ export default function WalletSettings () {
|
||||||
<WalletButtonBar
|
<WalletButtonBar
|
||||||
wallet={wallet} onDelete={async () => {
|
wallet={wallet} onDelete={async () => {
|
||||||
try {
|
try {
|
||||||
wallet.clearConfig()
|
wallet.delete()
|
||||||
toaster.success('saved settings')
|
toaster.success('saved settings')
|
||||||
router.push('/settings/wallets')
|
router.push('/settings/wallets')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
const message = 'failed to detach: ' + err.message || err.toString?.()
|
const message = 'failed to detach: ' + err.message || err.toString?.()
|
||||||
wallet.logger.error(message)
|
|
||||||
toaster.danger(message)
|
toaster.danger(message)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue