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

View file

@ -1,5 +1,7 @@
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.Manga
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 ||
customArtist != null ||
customAuthor != null ||
@ -91,14 +93,30 @@ data class BackupManga(
customGenre != null ||
customStatus != 0
) {
return CustomMangaManager.MangaJson(
return CustomMangaManager.ComicList.ComicInfoYokai(
id = 0L,
title = customTitle,
author = customAuthor,
artist = customArtist,
description = customDescription,
genre = customGenre?.toTypedArray(),
status = customStatus.takeUnless { it == 0 },
value = ComicInfo(
title = null,
series = customTitle?.let { ComicInfo.Series(it) },
number = null,
writer = customAuthor?.let { ComicInfo.Writer(it) },
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

View file

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