From 10c64268c8af34edba4c8ea048f44b51603e3be9 Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Tue, 15 Oct 2024 22:20:58 +0200 Subject: [PATCH] fixed limit --- backend/repositories/gemsRepository.ts | 1 + src/components/LeaderboardButton.tsx | 2 +- src/views/collection/Collection.tsx | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/repositories/gemsRepository.ts b/backend/repositories/gemsRepository.ts index d4c254c..9d94fb2 100644 --- a/backend/repositories/gemsRepository.ts +++ b/backend/repositories/gemsRepository.ts @@ -33,6 +33,7 @@ export const removeGems = async ( gems: number, ) => { const { count, totalCount } = await getGems(db, user); + if (count - gems < 0) throw new Error("Not enough gems"); await db .update(Gems) .set({ count: count - gems, totalCount: totalCount - gems }) diff --git a/src/components/LeaderboardButton.tsx b/src/components/LeaderboardButton.tsx index 2bfb4b9..c7b853b 100644 --- a/src/components/LeaderboardButton.tsx +++ b/src/components/LeaderboardButton.tsx @@ -16,7 +16,7 @@ interface LeaderboardButtonProps { const LeaderboardButton = ({ label = "View Full Leaderboard", }: LeaderboardButtonProps) => { - const { data: leaderboard } = useWSQuery("scoreboard.getScoreBoard", 10); + const { data: leaderboard } = useWSQuery("scoreboard.getScoreBoard", 100); return ( diff --git a/src/views/collection/Collection.tsx b/src/views/collection/Collection.tsx index af305aa..92a5193 100644 --- a/src/views/collection/Collection.tsx +++ b/src/views/collection/Collection.tsx @@ -29,6 +29,8 @@ const Collection = () => { (e) => e.id === theme.id && e.selected, ); const owned = collection?.entries.some((e) => e.id === theme.id); + const times = + collection?.entries.filter((e) => e.id === theme.id).length || 0; if (!owned) return null; return (
@@ -36,7 +38,10 @@ const Collection = () => {

{theme.name} {owned && ( - (Owned) + + {" "} + (Owned{times > 1 && ` ${times}x`}) + )}

{owned && (