Update title when refreshing the manga

This commit is contained in:
Jobobby04 2022-07-28 18:55:56 -04:00
parent 4ce66fecb9
commit 441368442e

View File

@ -7,6 +7,7 @@ import eu.kanade.domain.manga.model.isLocal
import eu.kanade.domain.manga.model.toDbManga
import eu.kanade.domain.manga.repository.MangaRepository
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.download.DownloadManager
import tachiyomi.source.model.MangaInfo
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@ -29,9 +30,16 @@ class UpdateManga(
remoteManga: MangaInfo,
manualFetch: Boolean,
coverCache: CoverCache = Injekt.get(),
// SY -->
downloadManager: DownloadManager = Injekt.get(),
// SY <--
): Boolean {
// if the manga isn't a favorite, set its title from source and update in db
val title = if (!localManga.favorite) remoteManga.title else null
// SY -->
val title = if (remoteManga.title.isNotBlank() && localManga.ogTitle != remoteManga.title) {
downloadManager.renameMangaDir(localManga.ogTitle, remoteManga.title, localManga.source)
remoteManga.title
} else null
// SY <--
// Never refresh covers if the url is empty to avoid "losing" existing covers
val updateCover = remoteManga.cover.isNotEmpty() && (manualFetch || localManga.thumbnailUrl != remoteManga.cover)