Fix recv wallet deleted on logout (#1398)
* Fix recv wallet deleted on logout * Fix wallet logs on server deleted on logout * Remove unused option in deleteLogs to override wallet
This commit is contained in:
parent
a6713f9793
commit
24aacd8839
|
@ -209,8 +209,8 @@ export const WalletLoggerProvider = ({ children }) => {
|
|||
setLogs((prevLogs) => [log, ...prevLogs])
|
||||
}, [saveLog])
|
||||
|
||||
const deleteLogs = useCallback(async (wallet) => {
|
||||
if (!wallet || wallet.walletType) {
|
||||
const deleteLogs = useCallback(async (wallet, options) => {
|
||||
if ((!wallet || wallet.walletType) && !options?.clientOnly) {
|
||||
await deleteServerWalletLogs({ variables: { wallet: wallet?.walletType } })
|
||||
}
|
||||
if (!wallet || wallet.sendPayment) {
|
||||
|
@ -262,7 +262,9 @@ export function useWalletLogger (wallet) {
|
|||
error: (...message) => log('error')(message.join(' '))
|
||||
}), [log, wallet?.name])
|
||||
|
||||
const deleteLogs = useCallback((w) => innerDeleteLogs(w || wallet), [innerDeleteLogs, wallet])
|
||||
const deleteLogs = useCallback((options) => {
|
||||
return innerDeleteLogs(wallet, options)
|
||||
}, [innerDeleteLogs, wallet])
|
||||
|
||||
return { logger, deleteLogs }
|
||||
}
|
||||
|
|
|
@ -77,9 +77,9 @@ export function useWallet (name) {
|
|||
}, [saveConfig, me, logger])
|
||||
|
||||
// delete is a reserved keyword
|
||||
const delete_ = useCallback(async () => {
|
||||
const delete_ = useCallback(async (options) => {
|
||||
try {
|
||||
await clearConfig({ logger })
|
||||
await clearConfig({ logger, ...options })
|
||||
} catch (err) {
|
||||
const message = err.message || err.toString?.()
|
||||
logger.error(message)
|
||||
|
@ -87,6 +87,11 @@ export function useWallet (name) {
|
|||
}
|
||||
}, [clearConfig, logger, disablePayments])
|
||||
|
||||
const deleteLogs_ = useCallback(async (options) => {
|
||||
// first argument is to override the wallet
|
||||
return await deleteLogs(options)
|
||||
}, [deleteLogs])
|
||||
|
||||
if (!wallet) return null
|
||||
|
||||
// Assign everything to wallet object so every function that is passed this wallet object in this
|
||||
|
@ -102,7 +107,7 @@ export function useWallet (name) {
|
|||
wallet.config = config
|
||||
wallet.save = save
|
||||
wallet.delete = delete_
|
||||
wallet.deleteLogs = deleteLogs
|
||||
wallet.deleteLogs = deleteLogs_
|
||||
wallet.setPriority = setPriority
|
||||
wallet.hasConfig = hasConfig
|
||||
wallet.status = status
|
||||
|
@ -237,13 +242,13 @@ function useConfig (wallet) {
|
|||
}
|
||||
}, [hasClientConfig, hasServerConfig, setClientConfig, setServerConfig, wallet])
|
||||
|
||||
const clearConfig = useCallback(async ({ logger }) => {
|
||||
const clearConfig = useCallback(async ({ logger, clientOnly }) => {
|
||||
if (hasClientConfig) {
|
||||
clearClientConfig()
|
||||
wallet.disablePayments()
|
||||
logger.ok('wallet detached for payments')
|
||||
}
|
||||
if (hasServerConfig) await clearServerConfig()
|
||||
if (hasServerConfig && !clientOnly) await clearServerConfig()
|
||||
}, [hasClientConfig, hasServerConfig, clearClientConfig, clearServerConfig, wallet])
|
||||
|
||||
return [config, saveConfig, clearConfig]
|
||||
|
@ -404,9 +409,9 @@ export function useWallets () {
|
|||
const resetClient = useCallback(async (wallet) => {
|
||||
for (const w of wallets) {
|
||||
if (w.canSend) {
|
||||
await w.delete()
|
||||
await w.delete({ clientOnly: true })
|
||||
}
|
||||
await w.deleteLogs()
|
||||
await w.deleteLogs({ clientOnly: true })
|
||||
}
|
||||
}, [wallets])
|
||||
|
||||
|
|
Loading…
Reference in New Issue