fix: fiabilité de la soumission du score en fin de partie

This commit is contained in:
herel committed 2026-08-29 09:05:38 +02:00
1 parent 2f73d2cd15
commit 639a34de5b
1 file changed
+8 -2
@@ -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,13 +65,17 @@ fun App(
config = current.config,
onFinish = { result ->
screen = Screen.Results(result)
scope.launch { history.save(result) }
scope.launch {
withContext(NonCancellable) { history.save(result) }
}
scope.launch {
withContext(NonCancellable) {
val score = result.leaderboardScore()
if (score > 0 && gamesServices.isSignedIn()) {
if (score > 0 && (gamesServices.isSignedIn() || gamesServices.signIn())) {
gamesServices.submitScore(result.config.leaderboardId(), score)
}
}
}
},
onQuit = { screen = Screen.Home },
)