mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 02:01:48 +01:00
parent
35d381144d
commit
e932983494
@ -54,6 +54,7 @@ import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
|||||||
import tachiyomi.domain.chapter.interactor.SetMangaDefaultChapterFlags
|
import tachiyomi.domain.chapter.interactor.SetMangaDefaultChapterFlags
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.domain.manga.interactor.GetDuplicateLibraryManga
|
import tachiyomi.domain.manga.interactor.GetDuplicateLibraryManga
|
||||||
|
import tachiyomi.domain.manga.interactor.GetManga
|
||||||
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.manga.model.toMangaUpdate
|
import tachiyomi.domain.manga.model.toMangaUpdate
|
||||||
@ -78,6 +79,7 @@ class BrowseSourceScreenModel(
|
|||||||
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
||||||
private val setMangaCategories: SetMangaCategories = Injekt.get(),
|
private val setMangaCategories: SetMangaCategories = Injekt.get(),
|
||||||
private val setMangaDefaultChapterFlags: SetMangaDefaultChapterFlags = Injekt.get(),
|
private val setMangaDefaultChapterFlags: SetMangaDefaultChapterFlags = Injekt.get(),
|
||||||
|
private val getManga: GetManga = Injekt.get(),
|
||||||
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
||||||
private val updateManga: UpdateManga = Injekt.get(),
|
private val updateManga: UpdateManga = Injekt.get(),
|
||||||
private val insertTrack: InsertTrack = Injekt.get(),
|
private val insertTrack: InsertTrack = Injekt.get(),
|
||||||
@ -121,19 +123,20 @@ class BrowseSourceScreenModel(
|
|||||||
) {
|
) {
|
||||||
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
|
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
|
||||||
}.flow.map { pagingData ->
|
}.flow.map { pagingData ->
|
||||||
pagingData
|
pagingData.map {
|
||||||
.map {
|
withIOContext {
|
||||||
flow {
|
networkToLocalManga.await(it.toDomainManga(sourceId))
|
||||||
val localManga = withIOContext { networkToLocalManga.await(it.toDomainManga(sourceId)) }
|
.let { localManga ->
|
||||||
emit(localManga)
|
getManga.subscribe(localManga.url, localManga.source)
|
||||||
}
|
}
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.filter {
|
.filter { localManga ->
|
||||||
!sourcePreferences.hideInLibraryItems().get() || !it.favorite
|
!sourcePreferences.hideInLibraryItems().get() || !localManga.favorite
|
||||||
}
|
}
|
||||||
.onEach(::initializeManga)
|
.onEach(::initializeManga)
|
||||||
.stateIn(coroutineScope)
|
.stateIn(coroutineScope)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.cachedIn(coroutineScope)
|
.cachedIn(coroutineScope)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user