fix: BackupManga should also use ComicInfo

This commit is contained in:
Ahmad Ansori Palembani 2024-05-29 12:38:13 +07:00
parent 96c3c3cc9a
commit 2283c7d5a8
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
3 changed files with 38 additions and 20 deletions

View file

@ -198,7 +198,7 @@ class BackupRestorer(val context: Context, val notifier: BackupNotifier) {
tracks: List<Track>, tracks: List<Track>,
backupCategories: List<BackupCategory>, backupCategories: List<BackupCategory>,
filteredScanlators: List<String>, filteredScanlators: List<String>,
customManga: CustomMangaManager.MangaJson?, customManga: CustomMangaManager.ComicList.ComicInfoYokai?,
) { ) {
val fetchedManga = manga.also { val fetchedManga = manga.also {
it.initialized = it.description != null it.initialized = it.description != null
@ -218,7 +218,7 @@ class BackupRestorer(val context: Context, val notifier: BackupNotifier) {
tracks: List<Track>, tracks: List<Track>,
backupCategories: List<BackupCategory>, backupCategories: List<BackupCategory>,
filteredScanlators: List<String>, filteredScanlators: List<String>,
customManga: CustomMangaManager.MangaJson?, customManga: CustomMangaManager.ComicList.ComicInfoYokai?,
) { ) {
restoreChapters(backupManga, chapters) restoreChapters(backupManga, chapters)
restoreExtras(backupManga, categories, history, tracks, backupCategories, filteredScanlators, customManga) restoreExtras(backupManga, categories, history, tracks, backupCategories, filteredScanlators, customManga)
@ -258,7 +258,7 @@ class BackupRestorer(val context: Context, val notifier: BackupNotifier) {
tracks: List<Track>, tracks: List<Track>,
backupCategories: List<BackupCategory>, backupCategories: List<BackupCategory>,
filteredScanlators: List<String>, filteredScanlators: List<String>,
customManga: CustomMangaManager.MangaJson?, customManga: CustomMangaManager.ComicList.ComicInfoYokai?,
) { ) {
restoreCategories(manga, categories, backupCategories) restoreCategories(manga, categories, backupCategories)
restoreHistoryForManga(history) restoreHistoryForManga(history)

View file

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.data.backup.models package eu.kanade.tachiyomi.data.backup.models
import dev.yokai.core.metadata.ComicInfo
import dev.yokai.core.metadata.ComicInfoPublishingStatus
import eu.kanade.tachiyomi.data.database.models.ChapterImpl import eu.kanade.tachiyomi.data.database.models.ChapterImpl
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.database.models.MangaImpl
@ -83,7 +85,7 @@ data class BackupManga(
} }
} }
fun getCustomMangaInfo(): CustomMangaManager.MangaJson? { fun getCustomMangaInfo(): CustomMangaManager.ComicList.ComicInfoYokai? {
if (customTitle != null || if (customTitle != null ||
customArtist != null || customArtist != null ||
customAuthor != null || customAuthor != null ||
@ -91,14 +93,30 @@ data class BackupManga(
customGenre != null || customGenre != null ||
customStatus != 0 customStatus != 0
) { ) {
return CustomMangaManager.MangaJson( return CustomMangaManager.ComicList.ComicInfoYokai(
id = 0L, id = 0L,
title = customTitle, value = ComicInfo(
author = customAuthor, title = null,
artist = customArtist, series = customTitle?.let { ComicInfo.Series(it) },
description = customDescription, number = null,
genre = customGenre?.toTypedArray(), writer = customAuthor?.let { ComicInfo.Writer(it) },
status = customStatus.takeUnless { it == 0 }, penciller = customArtist?.let { ComicInfo.Penciller(it) },
inker = null,
colorist = null,
letterer = null,
coverArtist = null,
translator = null,
summary = customDescription?.let { ComicInfo.Summary(it) },
genre = customGenre?.joinToString(", ")?.let { ComicInfo.Genre(it) },
tags = null,
web = null,
publishingStatus = customStatus.takeUnless { it == 0 }?.let { ComicInfo.PublishingStatusTachiyomi(
ComicInfoPublishingStatus.toComicInfoValue(status.toLong())
) },
categories = null,
source = null,
language = null,
)
) )
} }
return null return null

View file

@ -102,18 +102,18 @@ class CustomMangaManager(val context: Context) {
saveCustomInfo { jsonFile.delete() } saveCustomInfo { jsonFile.delete() }
} }
fun saveMangaInfo(manga: MangaJson) { fun saveMangaInfo(manga: ComicList.ComicInfoYokai) {
val mangaId = manga.id ?: return val mangaId = manga.id ?: return
if (manga.title == null && if (manga.value.series == null &&
manga.author == null && manga.value.writer == null &&
manga.artist == null && manga.value.penciller == null &&
manga.description == null && manga.value.summary == null &&
manga.genre == null && manga.value.genre == null &&
(manga.status ?: -1) == -1 (manga.value.publishingStatus?.value ?: "Invalid") == "Invalid"
) { ) {
customMangaMap.remove(mangaId) customMangaMap.remove(mangaId)
} else { } else {
customMangaMap[mangaId] = manga.toManga() customMangaMap[mangaId] = mangaFromComicInfoObject(mangaId, manga.value)
} }
saveCustomInfo() saveCustomInfo()
} }
@ -176,7 +176,7 @@ class CustomMangaManager(val context: Context) {
@XmlSerialName("ComicInfoYokai", "http://www.w3.org/2001/XMLSchema", "yk") @XmlSerialName("ComicInfoYokai", "http://www.w3.org/2001/XMLSchema", "yk")
data class ComicInfoYokai( data class ComicInfoYokai(
@XmlValue(true) val value: ComicInfo, @XmlValue(true) val value: ComicInfo,
val id: Long? = null, var id: Long? = null,
) )
} }