Skip to content

Commit

Permalink
refactor(web): implemented refetch interval
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilverma360 committed May 28, 2024
1 parent a769bbb commit f2540d8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion web/src/components/ClaimPnkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Button } from "@kleros/ui-components-library";
import FaucetIcon from "svgs/icons/faucet.svg";

import { DEFAULT_CHAIN } from "consts/chains";
import { REFETCH_INTERVAL } from "consts/index";
import {
simulatePnkFaucet,
useReadPnkBalanceOf,
Expand All @@ -26,12 +27,12 @@ const ClaimPnkButton: React.FC = () => {
const [isPopupOpen, setIsPopupOpen] = useState(false);
const [hash, setHash] = useState<`0x${string}` | undefined>();

// TODO watch
const chainId = useChainId();
const { address } = useAccount();
const { data: claimed } = useReadPnkFaucetWithdrewAlready({
query: {
enabled: !isUndefined(address),
refetchInterval: REFETCH_INTERVAL,
},
args: [address ?? "0x00"],
});
Expand Down
7 changes: 5 additions & 2 deletions web/src/components/Verdict/FinalDecision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useAccount } from "wagmi";

import ArrowIcon from "assets/svgs/icons/arrow.svg";

import { REFETCH_INTERVAL } from "consts/index";
import { Periods } from "consts/periods";
import { useReadKlerosCoreCurrentRuling } from "hooks/contracts/generated";
import { usePopulatedDisputeData } from "hooks/queries/usePopulatedDisputeData";
Expand Down Expand Up @@ -76,8 +77,10 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
const ruled = disputeDetails?.dispute?.ruled ?? false;
const periodIndex = Periods[disputeDetails?.dispute?.period ?? "evidence"];
const navigate = useNavigate();
// TODO block
const { data: currentRulingArray } = useReadKlerosCoreCurrentRuling({ args: [BigInt(id ?? 0)] });
const { data: currentRulingArray } = useReadKlerosCoreCurrentRuling({
query: { refetchInterval: REFETCH_INTERVAL },
args: [BigInt(id ?? 0)],
});
const currentRuling = Number(currentRulingArray?.[0]);
const answer = populatedDisputeData?.answers?.[currentRuling! - 1];
const buttonText = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { ArbitratorTypes };

export const ONE_BASIS_POINT = 10000n;

export const REFETCH_INTERVAL = 10000;
export const REFETCH_INTERVAL = 5000;

export const IPFS_GATEWAY = import.meta.env.REACT_APP_IPFS_GATEWAY || "https://cdn.kleros.link";
export const HERMES_TELEGRAM_BOT_URL =
Expand Down
3 changes: 2 additions & 1 deletion web/src/hooks/useVotingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useContext, createContext, useMemo } from "react";
import { useParams } from "react-router-dom";
import { useAccount } from "wagmi";

import { REFETCH_INTERVAL } from "consts/index";
import { useReadDisputeKitClassicIsVoteActive } from "hooks/contracts/generated";
import { useDisputeDetailsQuery } from "hooks/queries/useDisputeDetailsQuery";
import { useDrawQuery } from "hooks/queries/useDrawQuery";
Expand Down Expand Up @@ -34,10 +35,10 @@ export const VotingContextProvider: React.FC<{ children: React.ReactNode }> = ({
const { data: drawData, isLoading } = useDrawQuery(address?.toLowerCase(), id, disputeData?.dispute?.currentRound.id);
const roundId = disputeData?.dispute?.currentRoundIndex;
const voteId = drawData?.draws?.[0]?.voteIDNum;
// TODO watch
const { data: hasVoted } = useReadDisputeKitClassicIsVoteActive({
query: {
enabled: !isUndefined(roundId) && !isUndefined(voteId),
refetchInterval: REFETCH_INTERVAL,
},
args: [BigInt(id ?? 0), roundId, voteId],
});
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/Resolver/Parameters/Jurors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const StyledDisplay = styled(DisplaySmall)`

const Jurors: React.FC = () => {
const { disputeData, setDisputeData } = useNewDisputeContext();

const { data } = useReadKlerosCoreArbitrationCost({
query: {
enabled: !isUndefined(disputeData.numberOfJurors) && !Number.isNaN(disputeData.numberOfJurors),
Expand Down

0 comments on commit f2540d8

Please sign in to comment.