Fixed extensions showing as obsolete when call fails

This commit is contained in:
Jay 2020-01-13 18:30:20 -08:00
parent c2e1f7c09a
commit a44e9a19b0

View File

@ -159,6 +159,11 @@ class ExtensionManager(
* @param availableExtensions The list of extensions given by the [api].
*/
private fun updatedInstalledExtensionsStatuses(availableExtensions: List<Extension.Available>) {
if (availableExtensions.isEmpty())
{
preferences.extensionUpdatesCount().set(0)
return
}
val mutInstalledExtensions = installedExtensions.toMutableList()
var changed = false
var hasUpdateCount = 0
@ -166,12 +171,11 @@ class ExtensionManager(
val pkgName = installedExt.pkgName
val availableExt = availableExtensions.find { it.pkgName == pkgName }
if (availableExt == null) {
if (!installedExt.isObsolete) {
mutInstalledExtensions[index] = installedExt.copy(isObsolete = true)
changed = true
}
} else {
if (availableExt == null != installedExt.isObsolete) {
mutInstalledExtensions[index] = installedExt.copy(isObsolete = true)
changed = true
}
if (availableExt != null) {
val hasUpdate = availableExt.versionCode > installedExt.versionCode
if (installedExt.hasUpdate != hasUpdate) {
mutInstalledExtensions[index] = installedExt.copy(hasUpdate = hasUpdate)