Fix server config not updated after save or detach
This commit is contained in:
parent
c18263dc73
commit
645ff78365
|
@ -142,7 +142,7 @@ function useServerConfig (wallet) {
|
||||||
const client = useApolloClient()
|
const client = useApolloClient()
|
||||||
const me = useMe()
|
const me = useMe()
|
||||||
|
|
||||||
const { data } = useQuery(WALLET_BY_TYPE, { variables: { type: wallet?.server?.walletType }, skip: !wallet?.server })
|
const { data, refetch: refetchConfig } = useQuery(WALLET_BY_TYPE, { variables: { type: wallet?.server?.walletType }, skip: !wallet?.server })
|
||||||
|
|
||||||
const walletId = data?.walletByType?.id
|
const walletId = data?.walletByType?.id
|
||||||
const serverConfig = { id: walletId, priority: data?.walletByType?.priority, ...data?.walletByType?.wallet }
|
const serverConfig = { id: walletId, priority: data?.walletByType?.priority, ...data?.walletByType?.wallet }
|
||||||
|
@ -170,14 +170,16 @@ function useServerConfig (wallet) {
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
client.refetchQueries({ include: ['WalletLogs'] })
|
client.refetchQueries({ include: ['WalletLogs'] })
|
||||||
|
refetchConfig()
|
||||||
}
|
}
|
||||||
}, [client, walletId])
|
}, [client, walletId])
|
||||||
|
|
||||||
const clearConfig = useCallback(async () => {
|
const clearConfig = useCallback(async () => {
|
||||||
return await client.mutate({
|
await client.mutate({
|
||||||
mutation: REMOVE_WALLET,
|
mutation: REMOVE_WALLET,
|
||||||
variables: { id: walletId }
|
variables: { id: walletId }
|
||||||
})
|
})
|
||||||
|
refetchConfig()
|
||||||
}, [client, walletId])
|
}, [client, walletId])
|
||||||
|
|
||||||
return [config, saveConfig, clearConfig]
|
return [config, saveConfig, clearConfig]
|
||||||
|
|
Loading…
Reference in New Issue