This commit is contained in:
parent
958460db98
commit
42b75ecf2f
2 changed files with 15 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue