From 43d52e335ee40345c7ff309544d6860408d8b77f Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 1 Oct 2024 00:00:28 +0100 Subject: [PATCH] cache the beatsaver map --- src/components/score/score.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/score/score.tsx b/src/components/score/score.tsx index 47ae761..dd3f544 100644 --- a/src/components/score/score.tsx +++ b/src/components/score/score.tsx @@ -4,7 +4,7 @@ import BeatSaverMap from "@/common/database/types/beatsaver-map"; import ScoreSaberPlayerScoreToken from "@/common/model/token/scoresaber/score-saber-player-score-token"; import { beatsaverService } from "@/common/service/impl/beatsaver"; import LeaderboardScores from "@/components/leaderboard/leaderboard-scores"; -import { useCallback, useEffect, useState } from "react"; +import { cache, useCallback, useEffect, useState } from "react"; import ScoreButtons from "./score-buttons"; import ScoreSongInfo from "./score-info"; import ScoreRankInfo from "./score-rank-info"; @@ -23,7 +23,7 @@ export default function Score({ playerScore }: Props) { const [isLeaderboardExpanded, setIsLeaderboardExpanded] = useState(false); const fetchBeatSaverData = useCallback(async () => { - const beatSaverMap = await beatsaverService.lookupMap(leaderboard.songHash); + const beatSaverMap = await cache(async () => await beatsaverService.lookupMap(leaderboard.songHash))(); setBeatSaverMap(beatSaverMap); }, [leaderboard.songHash]);