fix(ssr): still show the youtube button even if the beatsaver map doesn't exist anymore
All checks were successful
deploy / deploy (push) Successful in 1m14s

This commit is contained in:
Lee 2023-11-24 20:50:51 +00:00
parent 407bcc866b
commit 4c0775b000

@ -30,6 +30,9 @@ export default function MapButtons({ leaderboard }: MapButtonsProps) {
return; return;
} }
const json = await beatSaberMap.json(); const json = await beatSaberMap.json();
if (json.maps[hash] !== null || json.maps[hash] !== undefined) {
return;
}
setMapId(json.maps[hash].id); setMapId(json.maps[hash].id);
}, [hash]); }, [hash]);
@ -40,55 +43,53 @@ export default function MapButtons({ leaderboard }: MapButtonsProps) {
return ( return (
<div className="hidden flex-col items-center justify-between gap-1 p-1 md:flex md:items-start md:justify-end"> <div className="hidden flex-col items-center justify-between gap-1 p-1 md:flex md:items-start md:justify-end">
{mapId && ( {mapId && (
<> <div className="flex gap-1">
<div className="flex gap-1"> <Tooltip>
<Tooltip> <TooltipTrigger>
<TooltipTrigger> <Link
<Link href={`https://beatsaver.com/maps/${mapId}`}
href={`https://beatsaver.com/maps/${mapId}`} target="_blank"
target="_blank" >
<Button
className="h-[30px] w-[30px] bg-neutral-700 p-1"
variant={"secondary"}
> >
<Button <BeatSaverLogo size={20} />
className="h-[30px] w-[30px] bg-neutral-700 p-1" </Button>
variant={"secondary"} </Link>
> </TooltipTrigger>
<BeatSaverLogo size={20} /> <TooltipContent>
</Button> <p>Click to open the map page</p>
</Link> </TooltipContent>
</TooltipTrigger> </Tooltip>
<TooltipContent>
<p>Click to open the map page</p>
</TooltipContent>
</Tooltip>
<CopyBsrButton mapId={mapId} /> <CopyBsrButton mapId={mapId} />
</div> </div>
<div className="flex gap-1">
<Tooltip>
<TooltipTrigger>
<Link
href={`${songNameToYouTubeLink(
leaderboard.songName,
leaderboard.songSubName,
leaderboard.songAuthorName,
)}`}
target="_blank"
>
<Button
className="h-[30px] w-[30px] bg-neutral-700 p-1"
variant={"secondary"}
>
<YouTubeLogo size={20} />
</Button>
</Link>
</TooltipTrigger>
<TooltipContent>
<p>Click to view the song on YouTube</p>
</TooltipContent>
</Tooltip>
</div>
</>
)} )}
<div className="flex gap-1">
<Tooltip>
<TooltipTrigger>
<Link
href={`${songNameToYouTubeLink(
leaderboard.songName,
leaderboard.songSubName,
leaderboard.songAuthorName,
)}`}
target="_blank"
>
<Button
className="h-[30px] w-[30px] bg-neutral-700 p-1"
variant={"secondary"}
>
<YouTubeLogo size={20} />
</Button>
</Link>
</TooltipTrigger>
<TooltipContent>
<p>Click to view the song on YouTube</p>
</TooltipContent>
</Tooltip>
</div>
</div> </div>
); );
} }