From e16727713cae4f440114e0553e4fea990c4a45d5 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 6 Nov 2023 18:36:21 +0000 Subject: [PATCH] fix(overlay): remove debug --- src/app/overlay/page.tsx | 39 +++++++++++++------------- src/components/overlay/PlayerStats.tsx | 6 ++-- src/utils/beatleader/api.ts | 6 ---- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/app/overlay/page.tsx b/src/app/overlay/page.tsx index e892e26..b6f2629 100644 --- a/src/app/overlay/page.tsx +++ b/src/app/overlay/page.tsx @@ -19,7 +19,7 @@ interface OverlayProps {} interface OverlayState { mounted: boolean; player: OverlayPlayer | undefined; - settings: any | undefined; + config: any | undefined; } export default class Overlay extends Component { @@ -28,7 +28,7 @@ export default class Overlay extends Component { this.state = { mounted: false, player: undefined, - settings: undefined, + config: undefined, }; } @@ -77,9 +77,6 @@ export default class Overlay extends Component { return; } this.setState({ mounted: true }); - if (!this.state.mounted) { - HttpSiraStatus.connectWebSocket(); - } const url = new URL(window.location.href); const searchParams = url.searchParams; @@ -88,24 +85,26 @@ export default class Overlay extends Component { if (!data) { return; } - const settings = JSON.parse(data); - this.setState({ settings: settings }); + const config = JSON.parse(data); + this.setState({ config: config }); + const settings = config.settings; - if (settings.settings.showPlayerStats) { - this.updatePlayer(settings.accountId, settings.platform); + if (settings.showPlayerStats) { + this.updatePlayer(config.accountId, config.platform); setInterval(() => { - this.updatePlayer(settings.accountId, settings.platform); + this.updatePlayer(config.accountId, config.platform); }, UPDATE_INTERVAL); } + + if (settings.showScoreStats || settings.showSongInfo) { + HttpSiraStatus.connectWebSocket(); + } } render() { - const { player } = this.state; + const { player, config, mounted } = this.state; - if ( - !this.state.mounted || - (!player && this.state.settings.settings.showPlayerStats) - ) { + if (!mounted || (!player && config.settings.showPlayerStats)) { return (
@@ -114,7 +113,7 @@ export default class Overlay extends Component { ); } - if (!this.state.settings) { + if (!config) { return (
@@ -144,12 +143,12 @@ export default class Overlay extends Component { return (
- {this.state.settings.settings.showPlayerStats && player && ( - + {config.settings.showPlayerStats && player && ( + )} - {this.state.settings.settings.showScoreStats && } + {config.settings.showScoreStats && }
- {this.state.settings.settings.showSongInfo && ( + {config.settings.showSongInfo && (
diff --git a/src/components/overlay/PlayerStats.tsx b/src/components/overlay/PlayerStats.tsx index 90e4ddd..4729649 100644 --- a/src/components/overlay/PlayerStats.tsx +++ b/src/components/overlay/PlayerStats.tsx @@ -6,7 +6,7 @@ import CountyFlag from "../CountryFlag"; type PlayerStatsProps = { player: OverlayPlayer; - settings: any; + config: any; }; const leaderboardImages: Record = { @@ -14,7 +14,7 @@ const leaderboardImages: Record = { beatleader: "/assets/logos/beatleader.png", }; -export default function PlayerStats({ player, settings }: PlayerStatsProps) { +export default function PlayerStats({ player, config }: PlayerStatsProps) { return (
Leaderboard logo diff --git a/src/utils/beatleader/api.ts b/src/utils/beatleader/api.ts index 9f4a2f2..3d99efc 100644 --- a/src/utils/beatleader/api.ts +++ b/src/utils/beatleader/api.ts @@ -28,9 +28,6 @@ async function fetchPlayerData( ); const json = await response.json(); - // Check if there was an error fetching the user data - console.log(json); - return json as BeatLeaderPlayer; } @@ -67,9 +64,6 @@ async function fetchScores( ); const json = await response.json(); - // Check if there was an error fetching the user data - console.log(json); - const metadata = json.metadata; return { scores: json.data as BeatleaderScore[],