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:
+1
-1
@@ -5,7 +5,7 @@ import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
class GetChapterByMangaId(
|
||||
class GetChaptersByMangaId(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
) {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
import tachiyomi.domain.manga.interactor.GetMergedReferencesById
|
||||
import tachiyomi.domain.manga.model.MergedMangaReference
|
||||
|
||||
class GetMergedChapterByMangaId(
|
||||
class GetMergedChaptersByMangaId(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val getMergedReferencesById: GetMergedReferencesById,
|
||||
) {
|
||||
@@ -18,6 +18,16 @@ data class Chapter(
|
||||
val isRecognizedNumber: Boolean
|
||||
get() = chapterNumber >= 0f
|
||||
|
||||
fun copyFrom(other: Chapter): Chapter {
|
||||
return copy(
|
||||
name = other.name,
|
||||
url = other.url,
|
||||
dateUpload = other.dateUpload,
|
||||
chapterNumber = other.chapterNumber,
|
||||
scanlator = other.scanlator?.ifBlank { null },
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun create() = Chapter(
|
||||
id = -1,
|
||||
|
||||
@@ -2,8 +2,8 @@ package tachiyomi.domain.history.interactor
|
||||
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetMergedChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetMergedChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.service.getChapterSort
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
@@ -11,9 +11,9 @@ import tachiyomi.domain.manga.interactor.GetManga
|
||||
import kotlin.math.max
|
||||
|
||||
class GetNextChapters(
|
||||
private val getChapterByMangaId: GetChapterByMangaId,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
// SY -->
|
||||
private val getMergedChapterByMangaId: GetMergedChapterByMangaId,
|
||||
private val getMergedChaptersByMangaId: GetMergedChaptersByMangaId,
|
||||
// SY <--
|
||||
private val getManga: GetManga,
|
||||
private val historyRepository: HistoryRepository,
|
||||
@@ -29,7 +29,7 @@ class GetNextChapters(
|
||||
|
||||
// SY -->
|
||||
if (manga.source == MERGED_SOURCE_ID) {
|
||||
val chapters = getMergedChapterByMangaId.await(mangaId)
|
||||
val chapters = getMergedChaptersByMangaId.await(mangaId)
|
||||
.sortedWith(getChapterSort(manga, sortDescending = false))
|
||||
|
||||
return if (onlyUnread) {
|
||||
@@ -39,7 +39,7 @@ class GetNextChapters(
|
||||
}
|
||||
}
|
||||
if (manga.isEhBasedManga()) {
|
||||
val chapters = getChapterByMangaId.await(mangaId)
|
||||
val chapters = getChaptersByMangaId.await(mangaId)
|
||||
.sortedWith(getChapterSort(manga, sortDescending = false))
|
||||
|
||||
return if (onlyUnread) {
|
||||
@@ -50,7 +50,7 @@ class GetNextChapters(
|
||||
}
|
||||
// SY <--
|
||||
|
||||
val chapters = getChapterByMangaId.await(mangaId)
|
||||
val chapters = getChaptersByMangaId.await(mangaId)
|
||||
.sortedWith(getChapterSort(manga, sortDescending = false))
|
||||
|
||||
return if (onlyUnread) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
@@ -11,7 +11,7 @@ import java.time.temporal.ChronoUnit
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
class FetchInterval(
|
||||
private val getChapterByMangaId: GetChapterByMangaId,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
) {
|
||||
|
||||
suspend fun toMangaUpdateOrNull(
|
||||
@@ -24,7 +24,7 @@ class FetchInterval(
|
||||
} else {
|
||||
window
|
||||
}
|
||||
val chapters = getChapterByMangaId.await(manga.id)
|
||||
val chapters = getChaptersByMangaId.await(manga.id)
|
||||
val interval = manga.fetchInterval.takeIf { it < 0 } ?: calculateInterval(
|
||||
chapters,
|
||||
dateTime.zone,
|
||||
|
||||
Reference in New Issue
Block a user