瀏覽代碼

Relay extension changes to sources controller (fixes #3002)

arkon 4 年之前
父節點
當前提交
f07fbcc196

+ 3 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt

@@ -12,6 +12,7 @@ import com.bluelinelabs.conductor.RouterTransaction
 import com.bluelinelabs.conductor.support.RouterPagerAdapter
 import com.google.android.material.badge.BadgeDrawable
 import com.google.android.material.tabs.TabLayout
+import com.jakewharton.rxrelay.PublishRelay
 import eu.kanade.tachiyomi.R
 import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 import eu.kanade.tachiyomi.databinding.PagerControllerBinding
@@ -41,6 +42,8 @@ class BrowseController :
 
     private val toExtensions = args.getBoolean(TO_EXTENSIONS_EXTRA, false)
 
+    val extensionListUpdateRelay: PublishRelay<Boolean> = PublishRelay.create()
+
     private var adapter: BrowseAdapter? = null
 
     override fun getTitle(): String? {

+ 3 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt

@@ -181,7 +181,9 @@ open class ExtensionController :
         drawExtensions()
 
         // Update badge on parent controller tab
-        (parentController as BrowseController).setExtensionUpdateBadge()
+        val ctrl = parentController as BrowseController
+        ctrl.setExtensionUpdateBadge()
+        ctrl.extensionListUpdateRelay.call(true)
     }
 
     private fun drawExtensions() {

+ 6 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt

@@ -92,6 +92,12 @@ class SourceController :
         adapter?.fastScroller = binding.fastScroller
 
         requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
+
+        // Update list on extension changes (e.g. new installation)
+        (parentController as BrowseController).extensionListUpdateRelay
+            .subscribeUntilDestroy {
+                presenter.updateSources()
+            }
     }
 
     override fun onDestroyView(view: View) {