From 42b75ecf2f754990be6f7710396aebfc70c28894 Mon Sep 17 00:00:00 2001 From: doomtube Date: Sat, 10 Jan 2026 18:26:11 -0500 Subject: [PATCH] fixes lol --- .../src/lib/components/ChessGameOverlay.svelte | 17 ++++++++++++++--- frontend/src/routes/settings/+page.svelte | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/ChessGameOverlay.svelte b/frontend/src/lib/components/ChessGameOverlay.svelte index fd452f6..58a35be 100644 --- a/frontend/src/lib/components/ChessGameOverlay.svelte +++ b/frontend/src/lib/components/ChessGameOverlay.svelte @@ -374,9 +374,20 @@ }); } - function handleClose() { - if ($gamesOverlay.matchId) { - nakama.leaveMatch($gamesOverlay.matchId); + async function handleClose() { + const matchId = $gamesOverlay.matchId; + const mode = $gameMode; + + // If this is a waiting challenge we created, cancel it properly + // (myColor === 'w' means we're white, which means we created the challenge) + if (matchId && mode === 'waiting' && myColor === 'w') { + try { + await nakama.cancelChallenge(matchId); + } catch (e) { + console.error('Failed to cancel challenge:', e); + } + } else if (matchId) { + nakama.leaveMatch(matchId); } if (unsubscribeMatch) { diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index b7f4af1..a73f306 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -3302,7 +3302,7 @@ bot.connect();