Clean up chapter restoring logic a bit
(cherry picked from commit ce5e10be955d8166f53de8118f8f12e76546b5ea) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt # domain/src/main/java/tachiyomi/domain/history/interactor/GetNextChapters.kt
This commit is contained in:
@@ -8,8 +8,8 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.category.interactor.SetMangaCategories
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByUrl
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
@@ -35,7 +35,7 @@ class EHentaiUpdateHelper(context: Context) {
|
||||
GalleryEntry.Serializer(),
|
||||
)
|
||||
private val getChapterByUrl: GetChapterByUrl by injectLazy()
|
||||
private val getChapterByMangaId: GetChapterByMangaId by injectLazy()
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId by injectLazy()
|
||||
private val getManga: GetManga by injectLazy()
|
||||
private val updateManga: UpdateManga by injectLazy()
|
||||
private val setMangaCategories: SetMangaCategories by injectLazy()
|
||||
@@ -64,7 +64,7 @@ class EHentaiUpdateHelper(context: Context) {
|
||||
getManga.await(mangaId)
|
||||
}
|
||||
val chapterList = async(Dispatchers.IO) {
|
||||
getChapterByMangaId.await(mangaId)
|
||||
getChaptersByMangaId.await(mangaId)
|
||||
}
|
||||
val history = async(Dispatchers.IO) {
|
||||
getHistoryByMangaId.await(mangaId)
|
||||
@@ -115,7 +115,7 @@ class EHentaiUpdateHelper(context: Context) {
|
||||
chapterRepository.updateAll(chapterUpdates)
|
||||
chapterRepository.addAll(newChapters)
|
||||
|
||||
val (newHistory, deleteHistory) = getHistory(getChapterByMangaId.await(accepted.manga.id), chainsAsChapters, chainsAsHistory)
|
||||
val (newHistory, deleteHistory) = getHistory(getChaptersByMangaId.await(accepted.manga.id), chainsAsChapters, chainsAsHistory)
|
||||
|
||||
// Delete the duplicate history first
|
||||
deleteHistory.forEach {
|
||||
|
||||
@@ -28,7 +28,7 @@ import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_CHARGING
|
||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_ONLY_ON_WIFI
|
||||
@@ -51,7 +51,7 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
private val logger: Logger = xLog()
|
||||
private val updateManga: UpdateManga by injectLazy()
|
||||
private val syncChaptersWithSource: SyncChaptersWithSource by injectLazy()
|
||||
private val getChapterByMangaId: GetChapterByMangaId by injectLazy()
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId by injectLazy()
|
||||
private val getFlatMetadataById: GetFlatMetadataById by injectLazy()
|
||||
private val insertFlatMetadata: InsertFlatMetadata by injectLazy()
|
||||
private val getExhFavoriteMangaWithMetadata: GetExhFavoriteMangaWithMetadata by injectLazy()
|
||||
@@ -92,7 +92,7 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
val chapter = getChapterByMangaId.await(manga.id).minByOrNull {
|
||||
val chapter = getChaptersByMangaId.await(manga.id).minByOrNull {
|
||||
it.dateUpload
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
val newChapters = source.getChapterList(manga.toSManga())
|
||||
|
||||
val new = syncChaptersWithSource.await(newChapters, manga, source)
|
||||
return new to getChapterByMangaId.await(manga.id)
|
||||
return new to getChaptersByMangaId.await(manga.id)
|
||||
} catch (t: Throwable) {
|
||||
if (t is EHentai.GalleryNotFoundException) {
|
||||
val meta = getFlatMetadataById.await(manga.id)?.raise<EHentaiSearchMetadata>()
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.update
|
||||
import tachiyomi.core.util.lang.launchIO
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.manga.interactor.GetManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
@@ -26,7 +26,7 @@ class PagePreviewScreenModel(
|
||||
private val mangaId: Long,
|
||||
private val getPagePreviews: GetPagePreviews = Injekt.get(),
|
||||
private val getManga: GetManga = Injekt.get(),
|
||||
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId = Injekt.get(),
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
) : StateScreenModel<PagePreviewState>(PagePreviewState.Loading) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class PagePreviewScreenModel(
|
||||
init {
|
||||
screenModelScope.launchIO {
|
||||
val manga = getManga.await(mangaId)!!
|
||||
val chapter = getChapterByMangaId.await(mangaId).minByOrNull { it.sourceOrder }
|
||||
val chapter = getChaptersByMangaId.await(mangaId).minByOrNull { it.sourceOrder }
|
||||
if (chapter == null) {
|
||||
mutableState.update {
|
||||
PagePreviewState.Error(Exception("No chapters found"))
|
||||
|
||||
Reference in New Issue
Block a user