1- import React , { FC , Fragment } from 'react' ;
1+ import React , { FC , Fragment , useEffect } from 'react' ;
22import { Trans , useTranslation } from 'react-i18next' ;
33import { useNavigate } from 'react-router-dom' ;
44import { useAccount } from 'wagmi' ;
55
66import TipTile from 'components/shared/TipTile' ;
77import useMediaQuery from 'hooks/helpers/useMediaQuery' ;
8+ import useRefreshAntisybilStatus from 'hooks/mutations/useRefreshAntisybilStatus' ;
89import useCurrentEpoch from 'hooks/queries/useCurrentEpoch' ;
910import useIndividualReward from 'hooks/queries/useIndividualReward' ;
1011import useIsDecisionWindowOpen from 'hooks/queries/useIsDecisionWindowOpen' ;
@@ -20,12 +21,26 @@ const AllocationTipTiles: FC<AllocationTipTilesProps> = ({ className }) => {
2021 const { t, i18n } = useTranslation ( 'translation' , { keyPrefix : 'views.allocation.tip' } ) ;
2122 const navigate = useNavigate ( ) ;
2223 const { isDesktop } = useMediaQuery ( ) ;
23- const { isConnected } = useAccount ( ) ;
24+ const { address, isConnected } = useAccount ( ) ;
25+ const {
26+ mutateAsync : refreshAntisybilStatus ,
27+ isPending : isPendingRefreshAntisybilStatus ,
28+ isSuccess : isSuccessRefreshAntisybilStatus ,
29+ error : refreshAntisybilStatusError ,
30+ } = useRefreshAntisybilStatus ( ) ;
2431 const { data : currentEpoch } = useCurrentEpoch ( ) ;
2532 const { data : isDecisionWindowOpen } = useIsDecisionWindowOpen ( ) ;
2633 const { data : individualReward , isFetching : isFetchingIndividualReward } = useIndividualReward ( ) ;
2734 const { data : userAllocations , isFetching : isFetchingUserAllocation } = useUserAllocations ( ) ;
28- const { data : uqScore } = useUqScore ( isDecisionWindowOpen ? currentEpoch ! - 1 : currentEpoch ! ) ;
35+ const { data : uqScore , isFetching : isFetchingUqScore } = useUqScore (
36+ isDecisionWindowOpen ? currentEpoch ! - 1 : currentEpoch ! ,
37+ {
38+ enabled :
39+ isSuccessRefreshAntisybilStatus ||
40+ ( refreshAntisybilStatusError as null | { message : string } ) ?. message ===
41+ 'Address is already used for delegation' ,
42+ } ,
43+ ) ;
2944 const {
3045 wasRewardsAlreadyClosed,
3146 setWasRewardsAlreadyClosed,
@@ -40,10 +55,29 @@ const AllocationTipTiles: FC<AllocationTipTilesProps> = ({ className }) => {
4055 wasUqTooLowAlreadyClosed : state . data . wasUqTooLowAlreadyClosed ,
4156 } ) ) ;
4257
58+ useEffect ( ( ) => {
59+ if ( ! address ) {
60+ return ;
61+ }
62+ /**
63+ * The initial value of UQ for every user is 0.2.
64+ * It does not update automatically after delegation nor after change in Gitcoin Passport itself.
65+ *
66+ * We need to refreshAntisybilStatus to force BE to refetch current values from Gitcoin Passport
67+ * and return true value.
68+ */
69+ refreshAntisybilStatus ( address ! ) ;
70+ // eslint-disable-next-line react-hooks/exhaustive-deps
71+ } , [ ] ) ;
72+
4373 const isEpoch1 = currentEpoch === 1 ;
4474
4575 const isUqTooLowTipVisible =
46- ! ! isDecisionWindowOpen && uqScore === 20n && ! wasUqTooLowAlreadyClosed ;
76+ ! ! isDecisionWindowOpen &&
77+ ! isPendingRefreshAntisybilStatus &&
78+ ! isFetchingUqScore &&
79+ uqScore === 20n &&
80+ ! wasUqTooLowAlreadyClosed ;
4781
4882 const isRewardsTipVisible =
4983 ! isEpoch1 &&
0 commit comments