diff --git a/app/src/main/java/eu/kanade/data/source/SourceMapper.kt b/app/src/main/java/eu/kanade/data/source/SourceMapper.kt deleted file mode 100644 index 0f3dd2f9b..000000000 --- a/app/src/main/java/eu/kanade/data/source/SourceMapper.kt +++ /dev/null @@ -1,19 +0,0 @@ -package eu.kanade.data.source - -import eu.kanade.tachiyomi.source.CatalogueSource -import eu.kanade.tachiyomi.source.SourceManager -import tachiyomi.domain.source.model.Source - -val sourceMapper: (eu.kanade.tachiyomi.source.Source) -> Source = { source -> - Source( - source.id, - source.lang, - source.name, - supportsLatest = false, - isStub = source is SourceManager.StubSource, - ) -} - -val catalogueSourceMapper: (CatalogueSource) -> Source = { source -> - sourceMapper(source).copy(supportsLatest = source.supportsLatest) -} diff --git a/app/src/main/java/eu/kanade/data/source/SourceRepositoryImpl.kt b/app/src/main/java/eu/kanade/data/source/SourceRepositoryImpl.kt index e5b2285c6..bba4a6c3a 100644 --- a/app/src/main/java/eu/kanade/data/source/SourceRepositoryImpl.kt +++ b/app/src/main/java/eu/kanade/data/source/SourceRepositoryImpl.kt @@ -4,6 +4,7 @@ import eu.kanade.domain.source.repository.SourceRepository import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.online.HttpSource import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import tachiyomi.data.DatabaseHandler @@ -11,6 +12,7 @@ import tachiyomi.data.source.SourceLatestPagingSource import tachiyomi.data.source.SourcePagingSourceType import tachiyomi.data.source.SourcePopularPagingSource import tachiyomi.data.source.SourceSearchPagingSource +import tachiyomi.data.source.sourceMapper import tachiyomi.domain.source.model.Source import tachiyomi.domain.source.model.SourceWithCount import tachiyomi.source.local.LocalSource @@ -22,13 +24,19 @@ class SourceRepositoryImpl( override fun getSources(): Flow> { return sourceManager.catalogueSources.map { sources -> - sources.map(catalogueSourceMapper) + sources.map { + sourceMapper(it).copy( + supportsLatest = it.supportsLatest, + ) + } } } override fun getOnlineSources(): Flow> { - return sourceManager.onlineSources.map { sources -> - sources.map(sourceMapper) + return sourceManager.catalogueSources.map { sources -> + sources + .filterIsInstance() + .map(sourceMapper) } } @@ -38,8 +46,11 @@ class SourceRepositoryImpl( sourceIdsWithCount .filterNot { it.source == LocalSource.ID } .map { (sourceId, count) -> - val source = sourceMapper(sourceManager.getOrStub(sourceId)) - source to count + val source = sourceManager.getOrStub(sourceId) + val domainSource = sourceMapper(source).copy( + isStub = source is SourceManager.StubSource, + ) + domainSource to count } } } @@ -49,7 +60,10 @@ class SourceRepositoryImpl( return sourceIdWithNonLibraryManga.map { sourceId -> sourceId.map { (sourceId, count) -> val source = sourceManager.getOrStub(sourceId) - SourceWithCount(sourceMapper(source), count) + val domainSource = sourceMapper(source).copy( + isStub = source is SourceManager.StubSource, + ) + SourceWithCount(domainSource, count) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt index 81b4bde69..0d13b7b82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt @@ -40,7 +40,6 @@ class SourceManager( private val stubSourcesMap = ConcurrentHashMap() val catalogueSources: Flow> = sourcesMapFlow.map { it.values.filterIsInstance() } - val onlineSources: Flow> = catalogueSources.map { it.filterIsInstance() } init { scope.launch { diff --git a/data/src/main/java/tachiyomi/data/source/SourceMapper.kt b/data/src/main/java/tachiyomi/data/source/SourceMapper.kt index 416de4692..58ad123e9 100644 --- a/data/src/main/java/tachiyomi/data/source/SourceMapper.kt +++ b/data/src/main/java/tachiyomi/data/source/SourceMapper.kt @@ -1,7 +1,18 @@ package tachiyomi.data.source +import tachiyomi.domain.source.model.Source import tachiyomi.domain.source.model.SourceData +val sourceMapper: (eu.kanade.tachiyomi.source.Source) -> Source = { source -> + Source( + source.id, + source.lang, + source.name, + supportsLatest = false, + isStub = false, + ) +} + val sourceDataMapper: (Long, String, String) -> SourceData = { id, lang, name -> SourceData(id, lang, name) }