Skip to content

Commit

Permalink
Merge pull request #503 from starknet-id/fix/featured-quest-is-still-…
Browse files Browse the repository at this point in the history
…bugging

fix: featured quest is still bugging
  • Loading branch information
fricoben authored Feb 3, 2024
2 parents 499acbe + e5fc312 commit 1dbe7b9
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions context/QuestsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,19 @@ export const QuestsContextProvider = ({
setTrendingQuests(quests);
const notExpired = quests.filter((quest) => !quest.expired);
setFeaturedQuest(
notExpired.length >= 1
? notExpired[Math.floor(Math.random() * notExpired.length)]
: undefined
notExpired[Math.floor(Math.random() * notExpired.length)]
);
}
);
}, [address]);

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

useMemo(() => {
if (!address) return;
Expand Down

0 comments on commit 1dbe7b9

Please sign in to comment.