Subscribe to changes to manga in BrowseSourceScreen
Fixes #9235 (cherry picked from commit e932983494d34d87824dba5313a01337ac75742f) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt
This commit is contained in:
parent
2815068a00
commit
9c8c04c34d
@ -74,6 +74,7 @@ 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.GetFlatMetadataById
|
import tachiyomi.domain.manga.interactor.GetFlatMetadataById
|
||||||
|
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
|
||||||
@ -108,6 +109,7 @@ open 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(),
|
||||||
@ -199,15 +201,15 @@ open class BrowseSourceScreenModel(
|
|||||||
createSourcePagingSource(listing.query ?: "", listing.filters)
|
createSourcePagingSource(listing.query ?: "", listing.filters)
|
||||||
// SY <--
|
// SY <--
|
||||||
}.flow.map { pagingData ->
|
}.flow.map { pagingData ->
|
||||||
pagingData
|
pagingData.map { (it, metadata) ->
|
||||||
.map { (it, metadata) ->
|
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)
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -215,6 +217,7 @@ open class BrowseSourceScreenModel(
|
|||||||
// SY <--
|
// SY <--
|
||||||
.stateIn(coroutineScope)
|
.stateIn(coroutineScope)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.cachedIn(coroutineScope)
|
.cachedIn(coroutineScope)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user