Skip to content

Commit

Permalink
Merge pull request #1063 from Stepcu/fix-1011
Browse files Browse the repository at this point in the history
Fix: Update featured quest logic to prioritize recent quests
  • Loading branch information
Marchand-Nicolas authored Jan 24, 2025
2 parents 34d4282 + 419c095 commit c0517ea
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 @@ -130,6 +130,7 @@ export const QuestsContextProvider = ({

useMemo(() => {
if (!quests.length) return;

const notExpired = quests.filter((quest) => !quest.expired);
const lastBoostedQuest = boostedQuests.length
? quests.find(
Expand All @@ -138,8 +139,17 @@ export const QuestsContextProvider = ({
!quest.expired
)
: undefined;

const recentQuest = notExpired.find(
(quest) =>
quest.start_timestamp &&
new Date(quest.start_timestamp) >=
new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) // Check if less than a week ago
);

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

0 comments on commit c0517ea

Please sign in to comment.