diff --git a/components/rewards/RewardsPage.tsx b/components/rewards/RewardsPage.tsx
index e4138b05..54dcfcb4 100644
--- a/components/rewards/RewardsPage.tsx
+++ b/components/rewards/RewardsPage.tsx
@@ -5,7 +5,6 @@ import { useWallet } from '@solana/wallet-adapter-react'
import { useCurrentSeason, useIsAllClaimed } from 'hooks/useRewards'
import Season from './Season'
import ClaimPage from './Claim'
-import Loading from '@components/shared/Loading'
export const tiers = ['seed', 'mango', 'whale', 'bot']
@@ -16,17 +15,10 @@ const RewardsPage = () => {
const { data: seasonData } = useCurrentSeason()
const currentSeason = seasonData ? seasonData.season_id : undefined
const prevSeason = currentSeason ? currentSeason - 1 : undefined
- const { showClaim, loading: loadingShowClaim } = useIsAllClaimed(
- prevSeason,
- publicKey,
- )
+ const { showClaim } = useIsAllClaimed(prevSeason, publicKey)
return !showLeaderboards ? (
- loadingShowClaim ? (
-
-
-
- ) : showClaim ? (
+ showClaim ? (
) : (
diff --git a/hooks/useRewards.ts b/hooks/useRewards.ts
index 93869895..5331881d 100644
--- a/hooks/useRewards.ts
+++ b/hooks/useRewards.ts
@@ -81,13 +81,10 @@ export const useIsAllClaimed = (
prevSeason: number | undefined,
walletPk: PublicKey | null,
) => {
- const [isAllClaimed, setIsAllCliamed] = useState(false)
+ const [isAllClaimed, setIsAllCliamed] = useState(true)
const [showClaim, setShowClaim] = useState(true)
- const [loadingClaimed, setLoadingClaimed] = useState(true)
- const {
- data: distributionDataAndClient,
- isInitialLoading: loadingDistribution,
- } = useDistribution(prevSeason)
+ const [loading, setLoading] = useState(true)
+ const { data: distributionDataAndClient } = useDistribution(prevSeason)
const distributionData = distributionDataAndClient?.distribution
useEffect(() => {
@@ -98,18 +95,21 @@ export const useIsAllClaimed = (
const claimed = (
await distributionData?.getClaimed(walletPk)
)?.filter((x) => !x.equals(PublicKey.default))?.length
- setLoadingClaimed(false)
- setIsAllCliamed(!!toClaim && toClaim === claimed)
+ setLoading(false)
+ setIsAllCliamed(!toClaim || toClaim === claimed)
} catch (e) {
console.log('failed to check claimed rewards', e)
+ setLoading(false)
}
+ } else {
+ setIsAllCliamed(false)
}
}
handleGetIsAllClaimed()
}, [distributionData, walletPk])
useEffect(() => {
- if (distributionData && walletPk && !loadingClaimed) {
+ if (distributionData && walletPk) {
const start = distributionData.start.getTime()
const currentTimestamp = new Date().getTime()
const isClaimActive =
@@ -121,9 +121,6 @@ export const useIsAllClaimed = (
} else {
setShowClaim(false)
}
- }, [distributionData, walletPk, isAllClaimed, loadingClaimed])
-
- const loading = loadingClaimed || loadingDistribution
-
+ }, [distributionData, walletPk, isAllClaimed])
return { isAllClaimed, showClaim, loading }
}