mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 16:01:49 +01:00
Flatten available extensions with its source (#7956)
* Flatten available extensions with it's source We should also do something similar for installed extensions Supersedes #7200 * Dedupe sources
This commit is contained in:
parent
52fa28c16a
commit
c51e83c048
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.domain.extension.interactor
|
package eu.kanade.domain.extension.interactor
|
||||||
|
|
||||||
import eu.kanade.core.util.asFlow
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
@ -17,7 +16,10 @@ class GetExtensionLanguages(
|
|||||||
extensionManager.getAvailableExtensionsFlow(),
|
extensionManager.getAvailableExtensionsFlow(),
|
||||||
) { enabledLanguage, availableExtensions ->
|
) { enabledLanguage, availableExtensions ->
|
||||||
availableExtensions
|
availableExtensions
|
||||||
.map { it.lang }
|
.flatMap { ext ->
|
||||||
|
if (ext.sources.isEmpty()) listOf(ext.lang)
|
||||||
|
else ext.sources.map { it.lang }
|
||||||
|
}
|
||||||
.distinct()
|
.distinct()
|
||||||
.sortedWith(
|
.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
|
@ -36,9 +36,23 @@ class GetExtensionsByType(
|
|||||||
.filter { extension ->
|
.filter { extension ->
|
||||||
_installed.none { it.pkgName == extension.pkgName } &&
|
_installed.none { it.pkgName == extension.pkgName } &&
|
||||||
_untrusted.none { it.pkgName == extension.pkgName } &&
|
_untrusted.none { it.pkgName == extension.pkgName } &&
|
||||||
extension.lang in _activeLanguages &&
|
|
||||||
(showNsfwSources || extension.isNsfw.not())
|
(showNsfwSources || extension.isNsfw.not())
|
||||||
}
|
}
|
||||||
|
.flatMap { ext ->
|
||||||
|
if (ext.sources.isEmpty()) {
|
||||||
|
return@flatMap if (ext.lang in _activeLanguages) listOf(ext) else emptyList()
|
||||||
|
}
|
||||||
|
ext.sources.filter { it.lang in _activeLanguages }
|
||||||
|
.map {
|
||||||
|
ext.copy(
|
||||||
|
name = it.name,
|
||||||
|
lang = it.lang,
|
||||||
|
pkgName = "${ext.pkgName}-${it.id}",
|
||||||
|
sources = listOf(it),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
|
||||||
|
|
||||||
Extensions(updates, installed, available, untrusted)
|
Extensions(updates, installed, available, untrusted)
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,10 @@ class ExtensionsPresenter(
|
|||||||
.filter(queryFilter(searchQuery))
|
.filter(queryFilter(searchQuery))
|
||||||
.groupBy { LocaleHelper.getSourceDisplayName(it.lang, context) }
|
.groupBy { LocaleHelper.getSourceDisplayName(it.lang, context) }
|
||||||
.toSortedMap()
|
.toSortedMap()
|
||||||
.flatMap { (key, value) ->
|
.flatMap { (lang, exts) ->
|
||||||
listOf(
|
listOf(
|
||||||
ExtensionUiModel.Header.Text(key),
|
ExtensionUiModel.Header.Text(lang),
|
||||||
*value.map(extensionMapper(downloads)).toTypedArray(),
|
*exts.map(extensionMapper(downloads)).toTypedArray(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user