Fix extension installer running on loop when all updates for extensions are previously installed by app

This commit is contained in:
Jays2Kings 2021-08-07 13:21:56 -04:00
parent 9f31529870
commit 7dfbd6aab3
2 changed files with 19 additions and 17 deletions

View File

@ -109,7 +109,7 @@ class ExtensionInstallService(
} }
job?.invokeOnCompletion { job?.invokeOnCompletion {
if (showUpdatedNotification) { if (showUpdatedNotification && installedExtensions.size > 0) {
notifier.showUpdatedNotification(installedExtensions, preferences.hideNotificationContent()) notifier.showUpdatedNotification(installedExtensions, preferences.hideNotificationContent())
} }
if (reRunUpdateCheck || installedExtensions.size != list.size) { if (reRunUpdateCheck || installedExtensions.size != list.size) {

View File

@ -61,22 +61,24 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
val extensionManager = Injekt.get<ExtensionManager>() val extensionManager = Injekt.get<ExtensionManager>()
val extensionsInstalledByApp = val extensionsInstalledByApp =
extensions.filter { extensionManager.isInstalledByApp(it) } extensions.filter { extensionManager.isInstalledByApp(it) }
val intent = if (extensionsInstalledByApp.isNotEmpty()) {
ExtensionInstallService.jobIntent( val intent =
context, ExtensionInstallService.jobIntent(
extensionsInstalledByApp, context,
// Re reun this job if not all the extensions can be auto updated extensionsInstalledByApp,
if (extensionsInstalledByApp.size == extensions.size) { // Re run this job if not all the extensions can be auto updated
1 if (extensionsInstalledByApp.size == extensions.size) {
} else { 1
2 } else {
} 2
) }
context.startForegroundService(intent) )
if (extensionsInstalledByApp.size == extensions.size) { context.startForegroundService(intent)
return if (extensionsInstalledByApp.size == extensions.size) {
} else { return
extensions.removeAll(extensionsInstalledByApp) } else {
extensions.removeAll(extensionsInstalledByApp)
}
} }
} else { } else {
runJobAgain(context, NetworkType.UNMETERED) runJobAgain(context, NetworkType.UNMETERED)