Split the universal update queries into case-specific ones
Source-owned fields move out of MangaUpdate/ChapterUpdate into MangaRemoteUpdate/ChapterRemoteUpdate, which only UpdateMangaFromRemote and SyncChaptersWithSource write. Backup restore gets its own updateFromBackup queries for entries and chapters, writing only what a backup carries.
This commit is contained in:
@@ -3,6 +3,7 @@ package tachiyomi.domain.chapter.interactor
|
||||
import dev.zacsweers.metro.Inject
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
@@ -26,4 +27,12 @@ class UpdateChapter(
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun awaitAllRemote(chapterUpdates: List<ChapterRemoteUpdate>) {
|
||||
try {
|
||||
chapterRepository.updateAllRemote(chapterUpdates)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.chapter.model
|
||||
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class ChapterRemoteUpdate(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val scanlator: String?,
|
||||
val chapterNumber: Double,
|
||||
val dateUpload: Long?,
|
||||
val sourceOrder: Long,
|
||||
val memo: JsonObject,
|
||||
)
|
||||
@@ -1,7 +1,5 @@
|
||||
package tachiyomi.domain.chapter.model
|
||||
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class ChapterUpdate(
|
||||
val id: Long,
|
||||
val mangaId: Long? = null,
|
||||
@@ -9,29 +7,15 @@ data class ChapterUpdate(
|
||||
val bookmark: Boolean? = null,
|
||||
val lastPageRead: Long? = null,
|
||||
val dateFetch: Long? = null,
|
||||
val sourceOrder: Long? = null,
|
||||
val url: String? = null,
|
||||
val name: String? = null,
|
||||
val dateUpload: Long? = null,
|
||||
val chapterNumber: Double? = null,
|
||||
val scanlator: String? = null,
|
||||
val memo: JsonObject? = null,
|
||||
)
|
||||
|
||||
fun Chapter.toChapterUpdate(): ChapterUpdate {
|
||||
return ChapterUpdate(
|
||||
id,
|
||||
mangaId,
|
||||
read,
|
||||
bookmark,
|
||||
lastPageRead,
|
||||
dateFetch,
|
||||
sourceOrder,
|
||||
url,
|
||||
name,
|
||||
dateUpload,
|
||||
chapterNumber,
|
||||
scanlator,
|
||||
memo,
|
||||
id = id,
|
||||
mangaId = mangaId,
|
||||
read = read,
|
||||
bookmark = bookmark,
|
||||
lastPageRead = lastPageRead,
|
||||
dateFetch = dateFetch,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package tachiyomi.domain.chapter.repository
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
|
||||
interface ChapterRepository {
|
||||
@@ -12,6 +13,8 @@ interface ChapterRepository {
|
||||
|
||||
suspend fun updateAll(chapterUpdates: List<ChapterUpdate>)
|
||||
|
||||
suspend fun updateAllRemote(chapterUpdates: List<ChapterRemoteUpdate>)
|
||||
|
||||
suspend fun removeChaptersWithIds(chapterIds: List<Long>)
|
||||
|
||||
suspend fun getChapterByMangaId(mangaId: Long, applyScanlatorFilter: Boolean = false): List<Chapter>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package tachiyomi.domain.manga.model
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class MangaRemoteUpdate(
|
||||
val id: Long,
|
||||
val title: String?,
|
||||
val author: String?,
|
||||
val artist: String?,
|
||||
val description: String?,
|
||||
val genre: List<String>?,
|
||||
val status: Long,
|
||||
val thumbnailUrl: String?,
|
||||
val updateStrategy: UpdateStrategy,
|
||||
val memo: JsonObject,
|
||||
val initialized: Boolean,
|
||||
val coverLastModified: Long?,
|
||||
)
|
||||
@@ -1,11 +1,7 @@
|
||||
package tachiyomi.domain.manga.model
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class MangaUpdate(
|
||||
val id: Long,
|
||||
val source: Long? = null,
|
||||
val favorite: Boolean? = null,
|
||||
val lastUpdate: Long? = null,
|
||||
val nextUpdate: Long? = null,
|
||||
@@ -14,24 +10,12 @@ data class MangaUpdate(
|
||||
val viewerFlags: Long? = null,
|
||||
val chapterFlags: Long? = null,
|
||||
val coverLastModified: Long? = null,
|
||||
val url: String? = null,
|
||||
val title: String? = null,
|
||||
val artist: String? = null,
|
||||
val author: String? = null,
|
||||
val description: String? = null,
|
||||
val genre: List<String>? = null,
|
||||
val status: Long? = null,
|
||||
val thumbnailUrl: String? = null,
|
||||
val updateStrategy: UpdateStrategy? = null,
|
||||
val initialized: Boolean? = null,
|
||||
val notes: String? = null,
|
||||
val memo: JsonObject? = null,
|
||||
)
|
||||
|
||||
fun Manga.toMangaUpdate(): MangaUpdate {
|
||||
return MangaUpdate(
|
||||
id = id,
|
||||
source = source,
|
||||
favorite = favorite,
|
||||
lastUpdate = lastUpdate,
|
||||
nextUpdate = nextUpdate,
|
||||
@@ -40,17 +24,6 @@ fun Manga.toMangaUpdate(): MangaUpdate {
|
||||
viewerFlags = viewerFlags,
|
||||
chapterFlags = chapterFlags,
|
||||
coverLastModified = coverLastModified,
|
||||
url = url,
|
||||
title = title,
|
||||
artist = artist,
|
||||
author = author,
|
||||
description = description,
|
||||
genre = genre,
|
||||
status = status,
|
||||
thumbnailUrl = thumbnailUrl,
|
||||
updateStrategy = updateStrategy,
|
||||
initialized = initialized,
|
||||
notes = notes,
|
||||
memo = memo,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package tachiyomi.domain.manga.repository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaRemoteUpdate
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
|
||||
@@ -40,6 +41,8 @@ interface MangaRepository {
|
||||
|
||||
suspend fun update(update: MangaUpdate): Boolean
|
||||
|
||||
suspend fun updateRemote(update: MangaRemoteUpdate): Boolean
|
||||
|
||||
suspend fun updateAll(mangaUpdates: List<MangaUpdate>): Boolean
|
||||
|
||||
suspend fun insertNetworkManga(manga: List<Manga>): List<Manga>
|
||||
|
||||
Reference in New Issue
Block a user