From 2ced56e490ecd175b9575eda6514a933f2893a72 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:19:45 +0800 Subject: [PATCH] Fix error when updating manga details with uninitialized title (#8045) --- .../kanade/domain/manga/interactor/UpdateManga.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt index 220b27e94..8e0516a63 100644 --- a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt @@ -30,8 +30,14 @@ class UpdateManga( manualFetch: Boolean, coverCache: CoverCache = Injekt.get(), ): Boolean { + val remoteTitle = try { + remoteManga.title + } catch (_: UninitializedPropertyAccessException) { + "" + } + // 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 + val title = if (remoteTitle.isEmpty() || localManga.favorite) null else remoteTitle val coverLastModified = when { @@ -49,16 +55,18 @@ class UpdateManga( } } + val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() } + return mangaRepository.update( MangaUpdate( id = localManga.id, - title = title?.takeIf { it.isNotEmpty() }, + title = title, coverLastModified = coverLastModified, author = remoteManga.author, artist = remoteManga.artist, description = remoteManga.description, genre = remoteManga.getGenres(), - thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() }, + thumbnailUrl = thumbnailUrl, status = remoteManga.status.toLong(), initialized = true, ),