Skip to content

Commit

Permalink
fix: empty featured card (#494)
Browse files Browse the repository at this point in the history
* fix: empty featured card

* showing a regular quest as featured if no trending ones available
  • Loading branch information
Marchand-Nicolas authored Jan 31, 2024
1 parent def0fab commit 1eb7571
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions context/QuestsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ export const QuestsContextProvider = ({
);
}, [address]);

useMemo(() => {
if (!quests || featuredQuest) return;
const notExpired = quests.filter((quest) => !quest.expired);
setFeaturedQuest(
notExpired.length >= 1
? notExpired[Math.floor(Math.random() * notExpired.length)]
: undefined
);
}, [quests]);

useMemo(() => {
if (!address) return;
getCompletedBoosts(hexToDecimal(address)).then(
Expand Down

0 comments on commit 1eb7571

Please sign in to comment.