Skip to content

Commit

Permalink
fix activegame pause state
Browse files Browse the repository at this point in the history
  • Loading branch information
bqv committed Oct 11, 2023
1 parent 325b7b5 commit 1f3b91a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/io/zenandroid/onlinego/data/db/GameDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import io.zenandroid.onlinego.data.model.local.GameNotificationWithDetails
import io.zenandroid.onlinego.data.model.local.HistoricGamesMetadata
import io.zenandroid.onlinego.data.model.local.InitialState
import io.zenandroid.onlinego.data.model.local.Message
import io.zenandroid.onlinego.data.model.local.PauseControl
import io.zenandroid.onlinego.data.model.local.Player
import io.zenandroid.onlinego.data.model.local.Score
import io.zenandroid.onlinego.data.model.ogs.JosekiPosition
import io.zenandroid.onlinego.data.model.ogs.Phase
import io.zenandroid.onlinego.data.ogs.Pause
import kotlinx.coroutines.flow.Flow

private const val MAX_ALLOWED_SQL_PARAMS = 999
Expand Down Expand Up @@ -223,12 +225,15 @@ abstract class GameDao {
open fun updateClock(
id: Long,
playerToMoveId: Long?,
clock: Clock?) {
clock: Clock?,
pause: Pause?) {
getGame(id).blockingGet().let {
update(it.copy(
undoRequested = if(it.playerToMoveId != playerToMoveId) null else it.undoRequested,
playerToMoveId = playerToMoveId,
clock = clock,
pauseControl = (it.pauseControl ?: PauseControl())
.copy(pausedByThirdParty = pause?.paused),
pausedSince = when(clock?.newPausedState) {
true -> clock.newPausedSince
false -> null
Expand Down Expand Up @@ -429,4 +434,4 @@ abstract class GameDao {
updateChatMetadata(ChatMetadata(0, messages.last().chatId))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ class ActiveGamesRepository(
gameDao.updateClock(
id = gameId,
playerToMoveId = clock.current_player,
clock = Clock.fromOGSClock(clock)
clock = Clock.fromOGSClock(clock),
pause = clock.pause
)
}

Expand Down Expand Up @@ -388,4 +389,4 @@ class ActiveGamesRepository(
recordException(Exception(message, t))
Log.e("ActiveGameRespository", message, t)
}
}
}

0 comments on commit 1f3b91a

Please sign in to comment.