From 4671ce156492cb229a23f7748d6bb0b615cc24e3 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 12 Dec 2023 19:23:10 +0700 Subject: [PATCH] do It --- frontend/hooks/useJoinDaoLlcMutation.ts | 12 +++++++++++- staking/app/StakeConnection.ts | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/hooks/useJoinDaoLlcMutation.ts b/frontend/hooks/useJoinDaoLlcMutation.ts index 98e723f44..414710715 100644 --- a/frontend/hooks/useJoinDaoLlcMutation.ts +++ b/frontend/hooks/useJoinDaoLlcMutation.ts @@ -1,8 +1,11 @@ import { StakeAccount, StakeConnection } from '@pythnetwork/staking' import toast from 'react-hot-toast' -import { useMutation } from 'react-query' +import { useMutation, useQueryClient } from 'react-query' +import { StakeConnectionQueryKey } from './useStakeConnection' export function useJoinDaoLlcMutation() { + const queryClient = useQueryClient() + return useMutation( ['sign-llc-mutation'], async ({ @@ -16,6 +19,13 @@ export function useJoinDaoLlcMutation() { toast.success(`Successfully signed LLC agreement!`) }, { + onSuccess() { + // invalidate all except stake connection + queryClient.invalidateQueries({ + predicate: (query) => query.queryKey[0] !== StakeConnectionQueryKey, + }) + }, + onError(error: Error) { toast.error(error.message) }, diff --git a/staking/app/StakeConnection.ts b/staking/app/StakeConnection.ts index 5c63f0708..1d3c0bbf5 100644 --- a/staking/app/StakeConnection.ts +++ b/staking/app/StakeConnection.ts @@ -598,7 +598,7 @@ export class StakeConnection { } /** - * Join the DAO LLC for the give stake account. + * Join the DAO LLC for the given stake account. */ public async joinDaoLlc(stakeAccount: StakeAccount) { const transaction: Transaction = new Transaction();