Skip to content

Commit e71cd3b

Browse files
committed
Refetch wallets on change
1 parent da52ea8 commit e71cd3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

wallets/client/hooks/query.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { protocolTestSendPayment } from '@/wallets/client/protocols'
2424
import { timeoutSignal } from '@/lib/time'
2525
import { WALLET_SEND_PAYMENT_TIMEOUT_MS } from '@/lib/constants'
2626
import { useToast } from '@/components/toast'
27+
import { useMe } from '@/components/me'
2728

2829
export function useWalletsQuery () {
2930
const query = useQuery(WALLETS)
@@ -38,6 +39,8 @@ export function useWalletsQuery () {
3839
).then(wallets => setWallets(wallets))
3940
}, [query.data, decryptWallet])
4041

42+
useRefetchOnChange(query.refetch)
43+
4144
return useMemo(() => ({
4245
...query,
4346
// pretend query is still loading until we've decrypted the wallet
@@ -46,6 +49,13 @@ export function useWalletsQuery () {
4649
}), [query, wallets])
4750
}
4851

52+
function useRefetchOnChange (refetch) {
53+
const { me } = useMe()
54+
useEffect(() => {
55+
refetch()
56+
}, [refetch, me?.privates?.walletsUpdatedAt])
57+
}
58+
4959
export function useWalletQuery ({ id, name }) {
5060
const query = useQuery(WALLET, { variables: { id, name } })
5161
const [wallet, setWallet] = useState(null)

0 commit comments

Comments
 (0)