From 7d12e4d47ff98d8ef3c1067a73531b41314714e6 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 21 Jun 2025 21:51:42 +0200 Subject: [PATCH] fix results popup being bad after map already started and coord joins --- .../matches/[matchGuid]/+page.svelte | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte b/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte index 9e1f6be..148b84c 100644 --- a/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte +++ b/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte @@ -103,6 +103,17 @@ // Reactive statements $: isAnyPlayerPlaying = matchPlayers.some(player => (player.playState as any) === User_PlayStates.InGame); + $: if(isAnyPlayerPlaying && currentSong) { + matchPlayers + .filter(x => x.playState == User_PlayStates.InGame) + .forEach(player => { + const playerKey = `${player.guid}-${currentSong.beatmap.levelId.toLowerCase()}`; + if (!activeSongPlayers.has(playerKey)) { + activeSongPlayers.add(playerKey); + } + }); + } + if ($authTokenStore) { const cleanToken = $authTokenStore.replace('Bearer ', ''); client.setAuthToken(cleanToken); @@ -638,20 +649,23 @@ newRts.accuracy = calculateAccuracy(rts, map); // Check if any players are still playing this song - const playersStillPlaying = Array.from(activeSongPlayers) - .some(key => key.endsWith(`-${levelId.toLowerCase()}`)); + const playersStillPlaying = Array.from(activeSongPlayers).some(key => key.endsWith(`-${levelId.toLowerCase()}`)); + console.log("Players still playing:", playersStillPlaying) const completionType = playersStillPlaying ? 'Still Awaiting Scores' : 'Completed'; + console.log("CompletionType", completionType) // Find or create the result record const existingRecordIndex = previousMatchResults.findIndex(x => x.completionType === 'Still Awaiting Scores' && x.taData.gameplayParameters?.beatmap?.levelId.toUpperCase() === levelId.toUpperCase() ); + console.log("existingRecordIndex", existingRecordIndex) if (existingRecordIndex === -1) { + console.log("creating new record") previousMatchResults = [ { taData: map.taData,