diff --git a/app/src/main/java/io/zenandroid/onlinego/data/db/GameDao.kt b/app/src/main/java/io/zenandroid/onlinego/data/db/GameDao.kt index 8670e392..7f1f0b32 100644 --- a/app/src/main/java/io/zenandroid/onlinego/data/db/GameDao.kt +++ b/app/src/main/java/io/zenandroid/onlinego/data/db/GameDao.kt @@ -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 @@ -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 @@ -429,4 +434,4 @@ abstract class GameDao { updateChatMetadata(ChatMetadata(0, messages.last().chatId)) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/zenandroid/onlinego/data/repositories/ActiveGamesRepository.kt b/app/src/main/java/io/zenandroid/onlinego/data/repositories/ActiveGamesRepository.kt index dc364660..365ba293 100644 --- a/app/src/main/java/io/zenandroid/onlinego/data/repositories/ActiveGamesRepository.kt +++ b/app/src/main/java/io/zenandroid/onlinego/data/repositories/ActiveGamesRepository.kt @@ -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 ) } @@ -388,4 +389,4 @@ class ActiveGamesRepository( recordException(Exception(message, t)) Log.e("ActiveGameRespository", message, t) } -} \ No newline at end of file +}