fix(overlay): remove debug
All checks were successful
deploy / deploy (push) Successful in 59s

This commit is contained in:
Lee 2023-11-06 18:36:21 +00:00
parent 638dc528ad
commit e16727713c
3 changed files with 22 additions and 29 deletions

@ -19,7 +19,7 @@ interface OverlayProps {}
interface OverlayState { interface OverlayState {
mounted: boolean; mounted: boolean;
player: OverlayPlayer | undefined; player: OverlayPlayer | undefined;
settings: any | undefined; config: any | undefined;
} }
export default class Overlay extends Component<OverlayProps, OverlayState> { export default class Overlay extends Component<OverlayProps, OverlayState> {
@ -28,7 +28,7 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
this.state = { this.state = {
mounted: false, mounted: false,
player: undefined, player: undefined,
settings: undefined, config: undefined,
}; };
} }
@ -77,9 +77,6 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
return; return;
} }
this.setState({ mounted: true }); this.setState({ mounted: true });
if (!this.state.mounted) {
HttpSiraStatus.connectWebSocket();
}
const url = new URL(window.location.href); const url = new URL(window.location.href);
const searchParams = url.searchParams; const searchParams = url.searchParams;
@ -88,24 +85,26 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
if (!data) { if (!data) {
return; return;
} }
const settings = JSON.parse(data); const config = JSON.parse(data);
this.setState({ settings: settings }); this.setState({ config: config });
const settings = config.settings;
if (settings.settings.showPlayerStats) { if (settings.showPlayerStats) {
this.updatePlayer(settings.accountId, settings.platform); this.updatePlayer(config.accountId, config.platform);
setInterval(() => { setInterval(() => {
this.updatePlayer(settings.accountId, settings.platform); this.updatePlayer(config.accountId, config.platform);
}, UPDATE_INTERVAL); }, UPDATE_INTERVAL);
} }
if (settings.showScoreStats || settings.showSongInfo) {
HttpSiraStatus.connectWebSocket();
}
} }
render() { render() {
const { player } = this.state; const { player, config, mounted } = this.state;
if ( if (!mounted || (!player && config.settings.showPlayerStats)) {
!this.state.mounted ||
(!player && this.state.settings.settings.showPlayerStats)
) {
return ( return (
<main className="flex items-center !bg-transparent p-3"> <main className="flex items-center !bg-transparent p-3">
<Spinner /> <Spinner />
@ -114,7 +113,7 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
); );
} }
if (!this.state.settings) { if (!config) {
return ( return (
<main> <main>
<Container> <Container>
@ -144,12 +143,12 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
return ( return (
<main> <main>
<div> <div>
{this.state.settings.settings.showPlayerStats && player && ( {config.settings.showPlayerStats && player && (
<PlayerStats player={player} settings={this.state.settings} /> <PlayerStats player={player} config={config} />
)} )}
{this.state.settings.settings.showScoreStats && <ScoreStats />} {config.settings.showScoreStats && <ScoreStats />}
</div> </div>
{this.state.settings.settings.showSongInfo && ( {config.settings.showSongInfo && (
<div className="absolute bottom-0 left-0"> <div className="absolute bottom-0 left-0">
<SongInfo /> <SongInfo />
</div> </div>

@ -6,7 +6,7 @@ import CountyFlag from "../CountryFlag";
type PlayerStatsProps = { type PlayerStatsProps = {
player: OverlayPlayer; player: OverlayPlayer;
settings: any; config: any;
}; };
const leaderboardImages: Record<string, string> = { const leaderboardImages: Record<string, string> = {
@ -14,7 +14,7 @@ const leaderboardImages: Record<string, string> = {
beatleader: "/assets/logos/beatleader.png", beatleader: "/assets/logos/beatleader.png",
}; };
export default function PlayerStats({ player, settings }: PlayerStatsProps) { export default function PlayerStats({ player, config }: PlayerStatsProps) {
return ( return (
<div className="flex gap-2 p-2"> <div className="flex gap-2 p-2">
<Image <Image
@ -28,7 +28,7 @@ export default function PlayerStats({ player, settings }: PlayerStatsProps) {
<div className="flex gap-1"> <div className="flex gap-1">
<Image <Image
alt="Leaderboard logo" alt="Leaderboard logo"
src={leaderboardImages[settings.platform]} src={leaderboardImages[config.platform]}
width={36} width={36}
height={36} height={36}
/> />

@ -28,9 +28,6 @@ async function fetchPlayerData(
); );
const json = await response.json(); const json = await response.json();
// Check if there was an error fetching the user data
console.log(json);
return json as BeatLeaderPlayer; return json as BeatLeaderPlayer;
} }
@ -67,9 +64,6 @@ async function fetchScores(
); );
const json = await response.json(); const json = await response.json();
// Check if there was an error fetching the user data
console.log(json);
const metadata = json.metadata; const metadata = json.metadata;
return { return {
scores: json.data as BeatleaderScore[], scores: json.data as BeatleaderScore[],