Skip to content

Commit

Permalink
fix: expired featured quest (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchand-Nicolas authored Aug 8, 2024
1 parent eabcaf3 commit ee1ff0e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions context/QuestsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ export const QuestsContextProvider = ({
if (!quests.length) return;
const notExpired = quests.filter((quest) => !quest.expired);
const lastBoostedQuest = boostedQuests.length
? quests.find((quest) => quest.id === boostedQuests[boostedQuests.length - 1])
? quests.find(
(quest) =>
quest.id === boostedQuests[boostedQuests.length - 1] &&
!quest.expired
)
: undefined;

setFeaturedQuest(lastBoostedQuest || notExpired[Math.floor(Math.random() * notExpired.length)]);
setFeaturedQuest(
lastBoostedQuest ||
notExpired[Math.floor(Math.random() * notExpired.length)]
);
}, [quests, boostedQuests]);

const contextValues = useMemo(() => {
Expand Down

0 comments on commit ee1ff0e

Please sign in to comment.