From fdc3df9c153f9c57f6c02711902f4710c55fb90f Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Fri, 18 Oct 2024 18:40:06 +0200 Subject: [PATCH] force refresh client wallets when device sync is enabled --- components/device-sync.js | 5 +++++ fragments/wallet.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/device-sync.js b/components/device-sync.js index 73818aff..67273d3c 100644 --- a/components/device-sync.js +++ b/components/device-sync.js @@ -10,9 +10,11 @@ import CancelButton from './cancel-button' import * as yup from 'yup' import { deviceSyncSchema } from '@/lib/validate' import RefreshIcon from '@/svgs/refresh-line.svg' +import { useApolloClient } from '@apollo/client' export default function DeviceSync () { const { me } = useMe() + const apollo = useApolloClient() const [value, setVaultKey, clearVault, disconnectVault] = useVaultConfigurator() const showModal = useShowModal() @@ -105,6 +107,9 @@ export default function DeviceSync () { try { await setVaultKey(values.passphrase) await migrate() + apollo.cache.evict({ fieldName: 'BestWallets' }) + apollo.cache.gc() + await apollo.refetchQueries({ include: ['BestWallets'] }) } catch (e) { formik?.setErrors({ passphrase: e.message }) throw e diff --git a/fragments/wallet.js b/fragments/wallet.js index af8ba5a1..b5a0e820 100644 --- a/fragments/wallet.js +++ b/fragments/wallet.js @@ -209,7 +209,7 @@ export const BEST_WALLETS = gql` } ` export const BEST_SEND_WALLETS = gql` - query BestWallets { + query BestSendWallets { wallets (includeSenders: true, includeReceivers: false, onlyEnabled: true, prioritySort: "asc") { id priority