From 7dfbd6aab32289fc3d0fc3838929de33d4d0f280 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 7 Aug 2021 13:21:56 -0400 Subject: [PATCH] Fix extension installer running on loop when all updates for extensions are previously installed by app --- .../extension/ExtensionInstallService.kt | 2 +- .../tachiyomi/extension/ExtensionUpdateJob.kt | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionInstallService.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionInstallService.kt index 167bf65367..0487f09c92 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionInstallService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionInstallService.kt @@ -109,7 +109,7 @@ class ExtensionInstallService( } job?.invokeOnCompletion { - if (showUpdatedNotification) { + if (showUpdatedNotification && installedExtensions.size > 0) { notifier.showUpdatedNotification(installedExtensions, preferences.hideNotificationContent()) } if (reRunUpdateCheck || installedExtensions.size != list.size) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt index 4f8c6458d5..c1682ce620 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt @@ -61,22 +61,24 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam val extensionManager = Injekt.get() val extensionsInstalledByApp = extensions.filter { extensionManager.isInstalledByApp(it) } - val intent = - ExtensionInstallService.jobIntent( - context, - extensionsInstalledByApp, - // Re reun this job if not all the extensions can be auto updated - if (extensionsInstalledByApp.size == extensions.size) { - 1 - } else { - 2 - } - ) - context.startForegroundService(intent) - if (extensionsInstalledByApp.size == extensions.size) { - return - } else { - extensions.removeAll(extensionsInstalledByApp) + if (extensionsInstalledByApp.isNotEmpty()) { + val intent = + ExtensionInstallService.jobIntent( + context, + extensionsInstalledByApp, + // Re run this job if not all the extensions can be auto updated + if (extensionsInstalledByApp.size == extensions.size) { + 1 + } else { + 2 + } + ) + context.startForegroundService(intent) + if (extensionsInstalledByApp.size == extensions.size) { + return + } else { + extensions.removeAll(extensionsInstalledByApp) + } } } else { runJobAgain(context, NetworkType.UNMETERED)