Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boosts Quest Count Mismatch #818

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/pages/home/questAndCollectionTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ const QuestAndCollectionTabs: FunctionComponent<
}, [address]);

const completedBoostNumber = useMemo(
() => boosts?.filter((b) => completedBoostIds?.includes(b.id)).length,
() => boosts?.filter((b) => completedBoostIds?.includes(b.id) && ((new Date().getTime() - boost.expiry) / MILLISECONDS_PER_WEEK <= 3 &&
boost.expiry < Date.now())).length,
Comment on lines +116 to +117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the expiry condition logic.

The condition (new Date().getTime() - boost.expiry) / MILLISECONDS_PER_WEEK <= 3 && boost.expiry < Date.now() seems to have a logical error. The check should ensure that the boost is not expired rather than checking if it's within the last three weeks and expired. Consider revising the logic to accurately reflect the intended condition.

-    () => boosts?.filter((b) => completedBoostIds?.includes(b.id) && ((new Date().getTime() - boost.expiry) / MILLISECONDS_PER_WEEK <= 3 &&
-          boost.expiry < Date.now())).length,
+    () => boosts?.filter((b) => completedBoostIds?.includes(b.id) && (boost.expiry - new Date().getTime()) / MILLISECONDS_PER_WEEK <= 3).length,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
() => boosts?.filter((b) => completedBoostIds?.includes(b.id) && ((new Date().getTime() - boost.expiry) / MILLISECONDS_PER_WEEK <= 3 &&
boost.expiry < Date.now())).length,
() => boosts?.filter((b) => completedBoostIds?.includes(b.id) && (boost.expiry - new Date().getTime()) / MILLISECONDS_PER_WEEK <= 3).length,

[boosts, completedBoostIds]
);

Expand Down Expand Up @@ -223,13 +224,13 @@ const QuestAndCollectionTabs: FunctionComponent<
type={TEXT_TYPE.BODY_DEFAULT}
className={`${styles.categoryInfosText} text-gray-200 normal-case`}
>
{completedBoostNumber === boosts.length ? (
{completedBoostNumber === displayBoosts.length ? (
<span className="flex">
<span className="mr-2">All boosts done</span>
<CheckIcon width="24" color="#6AFFAF" />
</span>
) : (
`${completedBoostNumber}/${boosts.length} Boost${
`${completedBoostNumber}/${displayBoosts.length} Boost${
boosts.length > 1 ? "s" : ""
} done`
)}
Expand Down
Loading