From 8c69105fdb58e186a5cb9777e829926357bd9d0a Mon Sep 17 00:00:00 2001 From: davotoula Date: Mon, 23 Mar 2026 15:41:38 +0100 Subject: [PATCH] fix(chess): exclude own games from spectator list Skip adding games to spectatingGames when the user is a participant (playerPubkey or opponentPubkey matches userPubkey) or when the game is already finished. Co-Authored-By: Claude Sonnet 4.6 --- .../amethyst/commons/chess/ChessLobbyState.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessLobbyState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessLobbyState.kt index 1f5fbaf30..d33577f7a 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessLobbyState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessLobbyState.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.commons.chess import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip64Chess.Color +import com.vitorpamplona.quartz.nip64Chess.GameStatus import com.vitorpamplona.quartz.nip64Chess.LiveChessGameState import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -497,6 +498,14 @@ class ChessLobbyState( _activeGames.update { it + (gameId to state) } return } + // Don't add own games to spectating list + if (state.playerPubkey == userPubkey || state.opponentPubkey == userPubkey) { + return + } + // Don't add finished games to spectating list + if (state.gameStatus.value is GameStatus.Finished) { + return + } _spectatingGames.update { it + (gameId to state) } }