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')
|
||||
}, [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 {
|
||||
...wallet,
|
||||
sendPayment,
|
||||
validate,
|
||||
config,
|
||||
saveConfig,
|
||||
clearConfig,
|
||||
save,
|
||||
delete: delete_,
|
||||
enable,
|
||||
disable,
|
||||
isConfigured: !!config,
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function WalletSettings () {
|
|||
try {
|
||||
const newConfig = !wallet.isConfigured
|
||||
await wallet.validate(values)
|
||||
wallet.saveConfig(values)
|
||||
wallet.save(values)
|
||||
// enable wallet if checkbox was set or if wallet was just configured
|
||||
if (enabled || newConfig) wallet.enable()
|
||||
else wallet.disable()
|
||||
|
@ -61,13 +61,12 @@ export default function WalletSettings () {
|
|||
<WalletButtonBar
|
||||
wallet={wallet} onDelete={async () => {
|
||||
try {
|
||||
wallet.clearConfig()
|
||||
wallet.delete()
|
||||
toaster.success('saved settings')
|
||||
router.push('/settings/wallets')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
const message = 'failed to detach: ' + err.message || err.toString?.()
|
||||
wallet.logger.error(message)
|
||||
toaster.danger(message)
|
||||
}
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue