mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-21 10:38:55 +02:00
Clean up chapter restoring logic a bit
This commit is contained in:
@@ -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,
|
||||
) {
|
||||
|
@@ -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,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package tachiyomi.domain.history.interactor
|
||||
|
||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.service.getChapterSort
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
@@ -8,7 +8,7 @@ import tachiyomi.domain.manga.interactor.GetManga
|
||||
import kotlin.math.max
|
||||
|
||||
class GetNextChapters(
|
||||
private val getChapterByMangaId: GetChapterByMangaId,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
private val getManga: GetManga,
|
||||
private val historyRepository: HistoryRepository,
|
||||
) {
|
||||
@@ -20,7 +20,7 @@ class GetNextChapters(
|
||||
|
||||
suspend fun await(mangaId: Long, onlyUnread: Boolean = true): List<Chapter> {
|
||||
val manga = getManga.await(mangaId) ?: return emptyList()
|
||||
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