Browse Source

Fix extension update badge reset when app resumed (#6822)

Ivan Iskandar 3 years ago
parent
commit
ef600c0956

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt

@@ -34,7 +34,7 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
             return@coroutineScope Result.failure()
         }
 
-        if (pendingUpdates.isNotEmpty()) {
+        if (!pendingUpdates.isNullOrEmpty()) {
             createUpdateNotification(pendingUpdates.map { it.name })
         }
 

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt

@@ -39,10 +39,10 @@ internal class ExtensionGithubApi {
         }
     }
 
-    suspend fun checkForUpdates(context: Context): List<Extension.Installed> {
+    suspend fun checkForUpdates(context: Context): List<Extension.Installed>? {
         // Limit checks to once a day at most
         if (Date().time < preferences.lastExtCheck().get() + TimeUnit.DAYS.toMillis(1)) {
-            return emptyList()
+            return null
         }
 
         val extensions = findExtensions()

+ 3 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt

@@ -361,8 +361,9 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
 
             // Extension updates
             try {
-                val pendingUpdates = ExtensionGithubApi().checkForUpdates(this@MainActivity)
-                preferences.extensionUpdatesCount().set(pendingUpdates.size)
+                ExtensionGithubApi().checkForUpdates(this@MainActivity)?.let { pendingUpdates ->
+                    preferences.extensionUpdatesCount().set(pendingUpdates.size)
+                }
             } catch (e: Exception) {
                 logcat(LogPriority.ERROR, e)
             }