From c894dd8c6769366a01d3f527d9fda2c1cda0517a Mon Sep 17 00:00:00 2001 From: null Date: Thu, 18 Jun 2026 02:47:57 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20simplify=20finishGame=20to=20not=20requi?= =?UTF-8?q?re=20userId=20=E2=80=94=20first=20caller=20wins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/usecase/GameSessionManager.kt | 19 ++++++++----------- .../closer/ui/wheel/WheelCompleteScreen.kt | 3 +-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/app/closer/domain/usecase/GameSessionManager.kt b/app/src/main/java/app/closer/domain/usecase/GameSessionManager.kt index 873937c5..8e1b71dc 100644 --- a/app/src/main/java/app/closer/domain/usecase/GameSessionManager.kt +++ b/app/src/main/java/app/closer/domain/usecase/GameSessionManager.kt @@ -94,23 +94,20 @@ class GameSessionManager @Inject constructor( } /** - * Finish the session referenced by [handle] for the current user. + * Finish the session referenced by [handle]. */ - suspend fun finishGameForCurrentUser(handle: GameHandle): Result { - val userId = authRepository.currentUserId - ?: return Result.failure(Exception("Not signed in")) - return finishGame(handle.sessionId, handle.coupleId, userId) - } + suspend fun finishGameForCurrentUser(handle: GameHandle): Result = + finishGame(handle.sessionId, handle.coupleId) /** - * Finish the current session for a user. - * Marks the session as completed by this user. - * Notifies partner when both users have completed. + * Mark the session as completed for the couple. + * The first caller wins — the whole session flips to "completed" immediately. + * This is correct for pass-the-phone games; async partner-sync games would + * need per-user completion fields instead. */ suspend fun finishGame( sessionId: String, - coupleId: String, - userId: String + coupleId: String ): Result = runCatching { val currentSession = sessionRepository.getActiveSessionForCouple(coupleId) ?: throw Exception("No active session found") diff --git a/app/src/main/java/app/closer/ui/wheel/WheelCompleteScreen.kt b/app/src/main/java/app/closer/ui/wheel/WheelCompleteScreen.kt index 3ccfee5a..246c28c7 100644 --- a/app/src/main/java/app/closer/ui/wheel/WheelCompleteScreen.kt +++ b/app/src/main/java/app/closer/ui/wheel/WheelCompleteScreen.kt @@ -69,8 +69,7 @@ class WheelCompleteViewModel @Inject constructor( val couple = coupleRepository.getCoupleForUser(uid) ?: return@launch gameSessionManager.finishGame( sessionId = sessionId, - coupleId = couple.id, - userId = uid + coupleId = couple.id ) } }