Skip to content

Commit 4a72da5

Browse files
committed
fix: shutter flash
1 parent 9140890 commit 4a72da5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

web/src/hooks/useVotingContext.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const VotingContextProvider: React.FC<{ children: React.ReactNode }> = ({
3535
const { data: drawData, isLoading } = useDrawQuery(address?.toLowerCase(), id, disputeData?.dispute?.currentRound.id);
3636
const roundId = disputeData?.dispute?.currentRoundIndex;
3737
const voteId = drawData?.draws?.[0]?.voteIDNum;
38-
const { data: hasVoted } = useReadDisputeKitClassicIsVoteActive({
38+
const { data: hasVotedClassic } = useReadDisputeKitClassicIsVoteActive({
3939
query: {
4040
enabled: !isUndefined(roundId) && !isUndefined(voteId),
4141
refetchInterval: REFETCH_INTERVAL,
@@ -44,12 +44,20 @@ export const VotingContextProvider: React.FC<{ children: React.ReactNode }> = ({
4444
});
4545

4646
const wasDrawn = useMemo(() => !isUndefined(drawData) && drawData.draws.length > 0, [drawData]);
47-
const isHiddenVotes = useMemo(() => disputeData?.dispute?.court.hiddenVotes, [disputeData]);
47+
const isHiddenVotes = useMemo(() => disputeData?.dispute?.court.hiddenVotes ?? false, [disputeData]);
4848
const isCommitPeriod = useMemo(() => disputeData?.dispute?.period === "commit", [disputeData]);
4949
const isVotingPeriod = useMemo(() => disputeData?.dispute?.period === "vote", [disputeData]);
5050

5151
const commited = useMemo(() => !isUndefined(drawData) && drawData?.draws?.[0]?.vote?.commited, [drawData]);
5252
const commit = useMemo(() => drawData?.draws?.[0]?.vote?.commit, [drawData]);
53+
54+
const hasVoted = useMemo(() => {
55+
if (isHiddenVotes && isCommitPeriod) {
56+
return commited;
57+
}
58+
return hasVotedClassic;
59+
}, [isHiddenVotes, isCommitPeriod, commited, hasVotedClassic]);
60+
5361
return (
5462
<VotingContext.Provider
5563
value={useMemo(

web/src/pages/Cases/CaseDetails/Voting/Shutter/index.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ const Shutter: React.FC<IShutter> = ({ arbitrable, setIsOpen, dispute, currentPe
2626
const { isCommitPeriod, isVotingPeriod, commited } = useVotingContext();
2727
const voteIDs = useMemo(() => drawData?.draws?.map((draw) => draw.voteIDNum) as string[], [drawData]);
2828

29-
return id && isCommitPeriod && !commited ? (
30-
<ShutterCommit {...{ arbitrable, setIsOpen, voteIDs, refetch, dispute, currentPeriodIndex, isGated }} />
31-
) : id && isVotingPeriod ? (
32-
<Reveal {...{ setIsOpen, voteIDs, isGated }} />
33-
) : null;
29+
const shouldShowCommit = id && isCommitPeriod && !commited;
30+
const shouldShowReveal = id && isVotingPeriod;
31+
32+
if (shouldShowCommit) {
33+
return <ShutterCommit {...{ arbitrable, setIsOpen, voteIDs, refetch, dispute, currentPeriodIndex, isGated }} />;
34+
}
35+
36+
if (shouldShowReveal) {
37+
return <Reveal {...{ setIsOpen, voteIDs, isGated }} />;
38+
}
39+
40+
return null;
3441
};
3542

3643
export default Shutter;

0 commit comments

Comments
 (0)