LETS GO BABY
This commit is contained in:
@ -1,19 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import ScoreSaberPlayerScoresPageToken from "@/common/model/token/scoresaber/score-saber-player-scores-page-token";
|
||||
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||
import { ScoreSort } from "@/common/model/score/score-sort";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import Mini from "../ranking/mini";
|
||||
import PlayerHeader from "./player-header";
|
||||
import PlayerScores from "./player-scores";
|
||||
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
||||
import Card from "@/components/card";
|
||||
import PlayerBadges from "@/components/player/player-badges";
|
||||
import { useIsMobile } from "@/hooks/use-is-mobile";
|
||||
import { useIsVisible } from "@/hooks/use-is-visible";
|
||||
import { useRef } from "react";
|
||||
import PlayerCharts from "@/components/player/chart/player-charts";
|
||||
import ScoreSaberPlayer, { getScoreSaberPlayerFromToken } from "@ssr/common/types/player/impl/scoresaber-player";
|
||||
import ScoreSaberPlayerScoresPageToken from "@ssr/common/types/token/scoresaber/score-saber-player-scores-page-token";
|
||||
import { ScoreSort } from "@ssr/common/types/score/score-sort";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import { config } from "../../../config";
|
||||
|
||||
type Props = {
|
||||
initialPlayerData: ScoreSaberPlayer;
|
||||
@ -37,12 +38,18 @@ export default function PlayerData({
|
||||
let player = initialPlayerData;
|
||||
const { data, isLoading, isError } = useQuery({
|
||||
queryKey: ["player", player.id],
|
||||
queryFn: () => scoresaberService.lookupPlayer(player.id),
|
||||
queryFn: async (): Promise<ScoreSaberPlayer | undefined> => {
|
||||
const playerResponse = await scoresaberService.lookupPlayer(player.id);
|
||||
if (playerResponse == undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi);
|
||||
},
|
||||
staleTime: 1000 * 60 * 5, // Cache data for 5 minutes
|
||||
});
|
||||
|
||||
if (data && (!isLoading || !isError)) {
|
||||
player = data.player;
|
||||
player = data;
|
||||
}
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user