|
|
@ -22,7 +22,6 @@ import kotlinx.coroutines.flow.collectLatest
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
|
import kotlinx.coroutines.flow.stateIn
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.update
|
|
|
|
import kotlinx.coroutines.flow.update
|
|
|
|
import rx.Observable
|
|
|
|
import rx.Observable
|
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
@ -78,9 +77,9 @@ class ExtensionsPresenter(
|
|
|
|
presenterScope.launchIO {
|
|
|
|
presenterScope.launchIO {
|
|
|
|
combine(
|
|
|
|
combine(
|
|
|
|
_query,
|
|
|
|
_query,
|
|
|
|
getExtensions.subscribe().stateIn(presenterScope),
|
|
|
|
|
|
|
|
_currentDownloads,
|
|
|
|
_currentDownloads,
|
|
|
|
) { query, (_updates, _installed, _available, _untrusted), downloads ->
|
|
|
|
getExtensions.subscribe(),
|
|
|
|
|
|
|
|
) { query, downloads, (_updates, _installed, _available, _untrusted) ->
|
|
|
|
val searchQuery = query ?: ""
|
|
|
|
val searchQuery = query ?: ""
|
|
|
|
|
|
|
|
|
|
|
|
val languagesWithExtensions = _available
|
|
|
|
val languagesWithExtensions = _available
|
|
|
@ -137,16 +136,17 @@ class ExtensionsPresenter(
|
|
|
|
fun updateAllExtensions() {
|
|
|
|
fun updateAllExtensions() {
|
|
|
|
presenterScope.launchIO {
|
|
|
|
presenterScope.launchIO {
|
|
|
|
if (state.isEmpty) return@launchIO
|
|
|
|
if (state.isEmpty) return@launchIO
|
|
|
|
val items = state.items
|
|
|
|
state.items
|
|
|
|
items.mapNotNull {
|
|
|
|
.mapNotNull {
|
|
|
|
if (it !is ExtensionUiModel.Item) return@mapNotNull null
|
|
|
|
when {
|
|
|
|
if (it.extension !is Extension.Installed) return@mapNotNull null
|
|
|
|
it !is ExtensionUiModel.Item -> null
|
|
|
|
if (it.extension.hasUpdate.not()) return@mapNotNull null
|
|
|
|
it.extension !is Extension.Installed -> null
|
|
|
|
it.extension
|
|
|
|
!it.extension.hasUpdate -> null
|
|
|
|
}.forEach {
|
|
|
|
else -> it.extension
|
|
|
|
updateExtension(it)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.forEach { updateExtension(it) }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun installExtension(extension: Extension.Available) {
|
|
|
|
fun installExtension(extension: Extension.Available) {
|
|
|
|