Skip to content

Commit

Permalink
Only fetch yesterday reward if user have not closed for today
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jun 28, 2024
1 parent 789a118 commit aaf423a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/modals/HomePageModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,19 @@ export default function HomePageModals() {

const myAddress = useMyMainAddress() ?? ''

const { data: yesterdayReward } = getUserYesterdayRewardQuery.useQuery({
address: myAddress ?? '',
})
const [enableYesterdayReward, setEnableYesterdayReward] = useState(false)
const { data: yesterdayReward } = getUserYesterdayRewardQuery.useQuery(
{
address: myAddress ?? '',
},
{ enabled: enableYesterdayReward }
)
useEffect(() => {
if (!progressModalStorage.getIsClosed()) {
setEnableYesterdayReward(true)
}
}, [])

const hasEarnedAnything = !!(
Number(yesterdayReward?.earned.creator ?? '0') ||
Number(yesterdayReward?.earned.staker ?? '0')
Expand Down

0 comments on commit aaf423a

Please sign in to comment.