Merge pull request #196 from lucasnlm/new-release

Fix bug
This commit is contained in:
Lucas Nunes 2020-10-12 19:22:33 -03:00 committed by GitHub
commit 9c91fb365d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -750,7 +750,13 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
keepScreenOn(false) keepScreenOn(false)
if (!isResuming) { if (!isResuming) {
lifecycleScope.launch {
gameViewModel.saveGame()
gameViewModel.saveStats()
}
cloudSaveManager.uploadSave() cloudSaveManager.uploadSave()
gameViewModel.addNewTip() gameViewModel.addNewTip()
waitAndShowEndGameAlert( waitAndShowEndGameAlert(
@ -773,8 +779,10 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
if (!isResuming) { if (!isResuming) {
cloudSaveManager.uploadSave() cloudSaveManager.uploadSave()
GlobalScope.launch(context = Dispatchers.Main) { lifecycleScope.launch {
gameViewModel.gameOver(isResuming) gameViewModel.gameOver(isResuming)
gameViewModel.saveGame()
gameViewModel.saveStats()
waitAndShowEndGameAlert( waitAndShowEndGameAlert(
victory = false, victory = false,
await = true await = true

View file

@ -73,6 +73,8 @@ class SplashViewModel(
} catch (e: Exception) { } catch (e: Exception) {
null null
} }
}.distinctBy {
it.uid
}.forEach { }.forEach {
statsRepository.addStats(it) statsRepository.addStats(it)
} }

View file

@ -234,7 +234,7 @@ open class GameViewModel(
} }
} }
private suspend fun saveStats() { suspend fun saveStats() {
if (initialized) { if (initialized) {
gameController.let { gameController.let {
if (it.hasMines()) { if (it.hasMines()) {
@ -466,9 +466,6 @@ open class GameViewModel(
} }
viewModelScope.launch { viewModelScope.launch {
saveStats()
saveGame()
checkVictoryAchievements() checkVictoryAchievements()
} }
} }