Skip to content

Commit

Permalink
Merge pull request #1532 from IntersectMBO/fix/1404-dRepHash-of-undef…
Browse files Browse the repository at this point in the history
…ined

[#1404] improve query data type from any
  • Loading branch information
jdyczka authored Jul 16, 2024
2 parents 93b0542 + 6a08db6 commit 3761b68
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions govtool/frontend/src/context/pendingTransaction/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AutomatedVotingOptionCurrentDelegation,
AutomatedVotingOptionDelegationId,
} from "@/types/automatedVotingOptions";
import { CurrentDelegation, VoterInfo } from "@/models";

export const getDesiredResult = (
type: TransactionType,
Expand Down Expand Up @@ -61,11 +62,9 @@ export const refetchData = async (
if (queryKey === undefined) return;

await queryClient.invalidateQueries(queryKey);
// TODO add better type for query data
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data = await queryClient.getQueryData<any>(queryKey);

if (type === "delegate") {
const data = await queryClient.getQueryData<CurrentDelegation>(queryKey);
if (
resourceId === AutomatedVotingOptionDelegationId.no_confidence ||
resourceId === AutomatedVotingOptionDelegationId.abstain
Expand All @@ -74,6 +73,9 @@ export const refetchData = async (
}
return data?.dRepHash;
}

const data = await queryClient.getQueryData<VoterInfo>(queryKey);

if (type === "registerAsDrep" || type === "retireAsDrep")
return data?.isRegisteredAsDRep;
if (type === "registerAsDirectVoter" || type === "retireAsDirectVoter")
Expand Down

0 comments on commit 3761b68

Please sign in to comment.