mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Make syncChaptersWithSource use sqldelight (#7263)
* Make `syncChaptersWithSource` use sqldelight Will break chapter list live update on current ui Co-Authored-By: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> * Review Changes Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com>
This commit is contained in:
@@ -43,7 +43,7 @@ abstract class AbstractBackupManager(protected val context: Context) {
|
||||
internal suspend fun restoreChapters(source: Source, manga: Manga, chapters: List<Chapter>): Pair<List<Chapter>, List<Chapter>> {
|
||||
val fetchedChapters = source.getChapterList(manga.toMangaInfo())
|
||||
.map { it.toSChapter() }
|
||||
val syncedChapters = syncChaptersWithSource(db, fetchedChapters, manga, source)
|
||||
val syncedChapters = syncChaptersWithSource(fetchedChapters, manga, source)
|
||||
if (syncedChapters.first.isNotEmpty()) {
|
||||
chapters.forEach { it.manga_id = manga.id }
|
||||
updateChapters(chapters)
|
||||
|
||||
@@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||
import tachiyomi.source.model.MangaInfo
|
||||
import eu.kanade.domain.manga.model.Manga as DomainManga
|
||||
|
||||
interface Manga : SManga {
|
||||
|
||||
@@ -128,3 +129,26 @@ fun Manga.toMangaInfo(): MangaInfo {
|
||||
title = this.title,
|
||||
)
|
||||
}
|
||||
|
||||
fun Manga.toDomainManga(): DomainManga? {
|
||||
val mangaId = id ?: return null
|
||||
return DomainManga(
|
||||
id = mangaId,
|
||||
source = source,
|
||||
favorite = favorite,
|
||||
lastUpdate = last_update,
|
||||
dateAdded = date_added,
|
||||
viewerFlags = viewer_flags.toLong(),
|
||||
chapterFlags = chapter_flags.toLong(),
|
||||
coverLastModified = cover_last_modified,
|
||||
url = url,
|
||||
title = title,
|
||||
artist = artist,
|
||||
author = author,
|
||||
description = description,
|
||||
genre = getGenres(),
|
||||
status = status.toLong(),
|
||||
thumbnailUrl = thumbnail_url,
|
||||
initialized = initialized,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ class LibraryUpdateService(
|
||||
|
||||
// [dbmanga] was used so that manga data doesn't get overwritten
|
||||
// in case manga gets new chapter
|
||||
return syncChaptersWithSource(db, chapters, dbManga, source)
|
||||
return syncChaptersWithSource(chapters, dbManga, source)
|
||||
}
|
||||
|
||||
private suspend fun updateCovers() {
|
||||
|
||||
Reference in New Issue
Block a user