mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 19:15:06 +01:00
Fix null pointer exception on Extension Detail screen (#7666)
This commit is contained in:
parent
bfd22f8f2d
commit
6c7b3d7811
@ -14,10 +14,7 @@ import eu.kanade.tachiyomi.util.lang.launchUI
|
|||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.drop
|
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.take
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@ -36,13 +33,18 @@ class ExtensionDetailsPresenter(
|
|||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
extensionManager.getInstalledExtensionsFlow()
|
extensionManager.getInstalledExtensionsFlow()
|
||||||
.map { it.firstOrNull { it.pkgName == pkgName } }
|
.map { it.firstOrNull { it.pkgName == pkgName } }
|
||||||
.collectLatest {
|
.collectLatest { extension ->
|
||||||
state.extension = it
|
// If extension is null it's most likely uninstalled
|
||||||
|
if (extension == null) {
|
||||||
|
launchUI {
|
||||||
|
view?.onExtensionUninstalled()
|
||||||
|
}
|
||||||
|
return@collectLatest
|
||||||
|
}
|
||||||
|
state.extension = extension
|
||||||
fetchExtensionSources()
|
fetchExtensionSources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bindToUninstalledExtension()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CoroutineScope.fetchExtensionSources() {
|
private fun CoroutineScope.fetchExtensionSources() {
|
||||||
@ -63,21 +65,6 @@ class ExtensionDetailsPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindToUninstalledExtension() {
|
|
||||||
presenterScope.launchIO {
|
|
||||||
extensionManager.getInstalledExtensionsFlow()
|
|
||||||
.drop(1)
|
|
||||||
.filter { extensions -> extensions.none { it.pkgName == pkgName } }
|
|
||||||
.map { }
|
|
||||||
.take(1)
|
|
||||||
.collectLatest {
|
|
||||||
launchUI {
|
|
||||||
view?.onExtensionUninstalled()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uninstallExtension() {
|
fun uninstallExtension() {
|
||||||
val extension = extension ?: return
|
val extension = extension ?: return
|
||||||
extensionManager.uninstallExtension(extension.pkgName)
|
extensionManager.uninstallExtension(extension.pkgName)
|
||||||
|
Loading…
Reference in New Issue
Block a user