File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ const ProgressBar: React.FC<{
291
291
292
292
const VoteButton : React . FC < {
293
293
proposal : AtomWithQueryResult < Proposal > ;
294
- vote : AtomWithQueryResult < VoteType | undefined > ;
294
+ vote : AtomWithQueryResult < VoteType | null > ;
295
295
proposalId : bigint ;
296
296
} > = ( { proposal, vote, proposalId } ) => {
297
297
const navigate = useNavigate ( ) ;
@@ -317,7 +317,7 @@ const VoteButton: React.FC<{
317
317
const disabled =
318
318
! isExtensionConnected || ! canVote . data || status !== "ongoing" ;
319
319
320
- const voted = typeof vote . data !== "undefined" ;
320
+ const voted = vote . data !== null ;
321
321
const text = voted ? "Edit Vote" : "Vote" ;
322
322
323
323
return {
@@ -344,9 +344,9 @@ const VoteButton: React.FC<{
344
344
} ;
345
345
346
346
const VotedLabel : React . FC < {
347
- vote : AtomWithQueryResult < VoteType | undefined > ;
347
+ vote : AtomWithQueryResult < VoteType | null > ;
348
348
} > = ( { vote } ) => {
349
- if ( vote . isSuccess && typeof vote . data !== "undefined" ) {
349
+ if ( vote . isSuccess && vote . data !== null ) {
350
350
return (
351
351
< VotedLabelComponent vote = { vote . data } className = "text-xs min-w-22" />
352
352
) ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export const proposalFamily = atomFamily((id: bigint) =>
38
38
) ;
39
39
40
40
export const proposalVoteFamily = atomFamily ( ( id : bigint ) =>
41
- atomWithQuery < VoteType | undefined > ( ( get ) => {
41
+ atomWithQuery < VoteType | null > ( ( get ) => {
42
42
const votedProposals = get ( votedProposalsAtom ) ;
43
43
const enablePolling = get ( shouldUpdateProposalAtom ) ;
44
44
@@ -47,7 +47,9 @@ export const proposalVoteFamily = atomFamily((id: bigint) =>
47
47
refetchInterval : enablePolling ? 1000 : false ,
48
48
queryKey : [ "proposal-vote" , id . toString ( ) ] ,
49
49
...queryDependentFn ( async ( ) => {
50
- return votedProposals . data ! . find ( ( v ) => v . proposalId === id ) ?. vote ;
50
+ return (
51
+ votedProposals . data ! . find ( ( v ) => v . proposalId === id ) ?. vote ?? null
52
+ ) ;
51
53
} , [ votedProposals ] ) ,
52
54
} ;
53
55
} )
You can’t perform that action at this time.
0 commit comments