Always update fresh data from source if manga isn't favorited

This commit is contained in:
Cuong-Tran
2024-11-03 01:55:16 +07:00
parent 71d0d2d723
commit 47140c923f
6 changed files with 20 additions and 23 deletions

View File

@@ -113,11 +113,9 @@ class BrowseSourceScreenModel(
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
}.flow.map { pagingData ->
pagingData.map {
val networkManga = it.toDomainManga(sourceId)
networkToLocalManga.await(networkManga)
networkToLocalManga.await(it.toDomainManga(sourceId))
.let { localManga -> getManga.subscribe(localManga.url, localManga.source) }
.filterNotNull()
.map { manga -> manga.shouldUseNetworkMangaInfo(networkManga) }
.stateIn(ioCoroutineScope)
}
.filter { !hideInLibraryItems || !it.value.favorite }

View File

@@ -166,9 +166,7 @@ abstract class SearchScreenModel(
}
val titles = page.mangas.map {
val networkManga = it.toDomainManga(source.id)
networkToLocalManga.await(networkManga)
.shouldUseNetworkMangaInfo(networkManga)
networkToLocalManga.await(it.toDomainManga(source.id))
}
if (isActive) {

View File

@@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.update
import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.domain.chapter.interactor.GetChapterByUrlAndMangaId
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.interactor.GetMangaByUrlAndSourceId
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.service.SourceManager
@@ -27,7 +26,6 @@ class DeepLinkScreenModel(
private val sourceManager: SourceManager = Injekt.get(),
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
private val getChapterByUrlAndMangaId: GetChapterByUrlAndMangaId = Injekt.get(),
private val getMangaByUrlAndSourceId: GetMangaByUrlAndSourceId = Injekt.get(),
private val syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(),
) : StateScreenModel<DeepLinkScreenModel.State>(State.Loading) {
@@ -74,9 +72,7 @@ class DeepLinkScreenModel(
}
private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga {
val networkManga = sManga.toDomainManga(sourceId)
return networkToLocalManga.await(networkManga)
.shouldUseNetworkMangaInfo(networkManga)
return networkToLocalManga.await(sManga.toDomainManga(sourceId))
}
sealed interface State {