feat(chess): exit spectator mode with Leave Game button
Adds ability to leave a spectated game on both Android and Desktop: - Added stopSpectating() to ChessLobbyLogic (removes from state + stops polling) - Both ViewModels now delegate to logic.stopSpectating() instead of bypassing it - LiveChessGameScreen accepts onLeaveSpectating callback shown in spectator info area - Android: Leave Game button pops back stack and stops spectating - Desktop: Leave Game button clears selectedGameId (returns to lobby) and stops spectating Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
@@ -350,6 +350,15 @@ fun ChessGameScreen(
|
||||
onResign = { chessViewModel.resign(gameId) },
|
||||
isSpectatorOverride = isSpectating,
|
||||
onGameEndDismiss = { chessViewModel.dismissGame(gameId) },
|
||||
onLeaveSpectating =
|
||||
if (isSpectating) {
|
||||
{
|
||||
chessViewModel.stopSpectating(gameId)
|
||||
nav.popBack()
|
||||
}
|
||||
} else {
|
||||
null
|
||||
},
|
||||
whiteName = whiteDisplayName,
|
||||
whiteHex = whitePubkey,
|
||||
whiteAvatarUrl = whiteAvatarUrl,
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ class ChessViewModelNew(
|
||||
|
||||
fun loadGameAsSpectator(gameId: String) = logic.loadGameAsSpectator(gameId)
|
||||
|
||||
fun stopSpectating(gameId: String) = logic.state.removeSpectatingGame(gameId)
|
||||
fun stopSpectating(gameId: String) = logic.stopSpectating(gameId)
|
||||
|
||||
// ============================================
|
||||
// Utility
|
||||
|
||||
Reference in New Issue
Block a user