fix: fiabilité de la soumission du score en fin de partie
This commit is contained in:
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 },
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user