diff --git a/sharedUI/src/commonMain/kotlin/com/livrets/App.kt b/sharedUI/src/commonMain/kotlin/com/livrets/App.kt index 3418881..3055689 100644 --- a/sharedUI/src/commonMain/kotlin/com/livrets/App.kt +++ b/sharedUI/src/commonMain/kotlin/com/livrets/App.kt @@ -20,7 +20,9 @@ import com.livrets.ui.HistoryScreen import com.livrets.ui.HomeScreen import com.livrets.ui.ResultsScreen import com.livrets.ui.SwipeBack +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import okio.Path.Companion.toPath sealed interface Screen { @@ -63,11 +65,15 @@ fun App( config = current.config, onFinish = { result -> screen = Screen.Results(result) - scope.launch { history.save(result) } scope.launch { - val score = result.leaderboardScore() - if (score > 0 && gamesServices.isSignedIn()) { - gamesServices.submitScore(result.config.leaderboardId(), score) + withContext(NonCancellable) { history.save(result) } + } + scope.launch { + withContext(NonCancellable) { + val score = result.leaderboardScore() + if (score > 0 && (gamesServices.isSignedIn() || gamesServices.signIn())) { + gamesServices.submitScore(result.config.leaderboardId(), score) + } } } },