mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 07:47: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
3 changed files with 22 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.domain.extension.interactor
|
||||
|
||||
import eu.kanade.core.util.asFlow
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
|
@ -17,7 +16,10 @@ class GetExtensionLanguages(
|
|||
extensionManager.getAvailableExtensionsFlow(),
|
||||
) { enabledLanguage, availableExtensions ->
|
||||
availableExtensions
|
||||
.map { it.lang }
|
||||
.flatMap { ext ->
|
||||
if (ext.sources.isEmpty()) listOf(ext.lang)
|
||||
else ext.sources.map { it.lang }
|
||||
}
|
||||
.distinct()
|
||||
.sortedWith(
|
||||
compareBy(
|
||||
|
|
|
@ -36,9 +36,23 @@ class GetExtensionsByType(
|
|||
.filter { extension ->
|
||||
_installed.none { it.pkgName == extension.pkgName } &&
|
||||
_untrusted.none { it.pkgName == extension.pkgName } &&
|
||||
extension.lang in _activeLanguages &&
|
||||
(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)
|
||||
}
|
||||
|
|
|
@ -86,10 +86,10 @@ class ExtensionsPresenter(
|
|||
.filter(queryFilter(searchQuery))
|
||||
.groupBy { LocaleHelper.getSourceDisplayName(it.lang, context) }
|
||||
.toSortedMap()
|
||||
.flatMap { (key, value) ->
|
||||
.flatMap { (lang, exts) ->
|
||||
listOf(
|
||||
ExtensionUiModel.Header.Text(key),
|
||||
*value.map(extensionMapper(downloads)).toTypedArray(),
|
||||
ExtensionUiModel.Header.Text(lang),
|
||||
*exts.map(extensionMapper(downloads)).toTypedArray(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue