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) } }