Update mods even if we have cached data

This commit is contained in:
yairm210
2024-10-21 21:50:00 +03:00
parent 8f45b15c49
commit b0be185bf7

View File

@ -163,16 +163,14 @@ class ModManagementScreen private constructor(
if (isPortrait) initPortrait()
else initLandscape()
showLoadingImage()
if (installedModInfo.isEmpty())
refreshInstalledModInfo()
refreshInstalledModTable()
if (onlineModInfo.isEmpty())
reloadOnlineMods()
else
refreshOnlineModTable()
refreshOnlineModTable() // Refresh table - chances are we have cached data...
reloadOnlineMods() //... and still try to get fresh data from online
}
private fun initPortrait() {
@ -272,12 +270,7 @@ class ModManagementScreen private constructor(
}
}
private fun reloadOnlineMods() {
onlineModsTable.clear()
onlineModInfo.clear()
onlineModsTable.add(getDownloadFromUrlButton()).padBottom(15f).row()
tryDownloadPage(1)
}
private fun reloadOnlineMods() = tryDownloadPage(1)
/** background worker: querying GitHub for Mods (repos with 'unciv-mod' in its topics)
*
@ -312,9 +305,6 @@ class ModManagementScreen private constructor(
if (stopBackgroundTasks) return
repo.name = repo.name.repoNameToFolderName()
if (onlineModInfo.containsKey(repo.name))
continue // we already got this mod in a previous download, since one has been added in between
val installedMod = RulesetCache.values.firstOrNull { it.name == repo.name }
val isUpdatedVersionOfInstalledMod = installedMod?.modOptions?.let {
it.lastUpdated != "" && it.lastUpdated != repo.pushed_at
@ -346,6 +336,7 @@ class ModManagementScreen private constructor(
val mod = ModUIData(repo, isUpdatedVersionOfInstalledMod)
onlineModInfo[repo.name] = mod
modButtons.remove(mod) // Remove *cached* mod button since we have NEW DATA
onlineModsTable.add(getCachedModButton(mod)).row()
}