performance: Don't enqueue multiplayer game update for 0 games

This commit is contained in:
Yair Morgenstern 2023-09-05 19:07:36 +03:00
parent 855b2959a1
commit 4ddaf9b2c4

View File

@ -190,6 +190,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
fun startTurnChecker(applicationContext: Context, files: UncivFiles, currentGameInfo: GameInfo, settings: GameSettingsMultiplayer) {
Log.i(LOG_TAG, "startTurnChecker")
// Games that haven't been updated in a week are considered stale
val oneWeekWorthOfMilliseconds = 1000*60*60*24*7
val gameFiles = files.getMultiplayerSaves()
.filter { it.lastModified() > System.currentTimeMillis() - oneWeekWorthOfMilliseconds }
@ -209,6 +210,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
//just skip one file
}
}
if (count==0) return // no games to update
Log.d(LOG_TAG, "start gameNames: ${gameNames.contentToString()}")