cache the beatsaver map
All checks were successful
Deploy / deploy (push) Successful in 7m38s

This commit is contained in:
Lee 2024-10-01 00:00:28 +01:00
parent 794de708b9
commit 43d52e335e

@ -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]);