From eaa0944b4961064f950244250b0de1b6815dac4f Mon Sep 17 00:00:00 2001 From: Cuong-Tran Date: Thu, 21 Nov 2024 01:09:11 +0700 Subject: [PATCH] inline manga update --- .../manga/interactor/NetworkToLocalManga.kt | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/domain/src/main/java/tachiyomi/domain/manga/interactor/NetworkToLocalManga.kt b/domain/src/main/java/tachiyomi/domain/manga/interactor/NetworkToLocalManga.kt index 50c505c9a0..509155e2df 100644 --- a/domain/src/main/java/tachiyomi/domain/manga/interactor/NetworkToLocalManga.kt +++ b/domain/src/main/java/tachiyomi/domain/manga/interactor/NetworkToLocalManga.kt @@ -17,7 +17,13 @@ class NetworkToLocalManga( } !localManga.favorite -> { // if the manga isn't a favorite, update new info from source to db - manga.updateManga(localManga.id) + mangaRepository.update( + manga.toMangaUpdate() + .copy( + id = localManga.id, + thumbnailUrl = manga.thumbnailUrl?.takeIf { it.isNotBlank() }, + ), + ) manga.copy(id = localManga.id) } else -> { @@ -33,14 +39,4 @@ class NetworkToLocalManga( private suspend fun insertManga(manga: Manga): Long? { return mangaRepository.insert(manga) } - - private suspend fun Manga.updateManga(id: Long) { - mangaRepository.update( - toMangaUpdate() - .copy( - id = id, - thumbnailUrl = thumbnailUrl?.takeIf { it.isNotBlank() }, - ), - ) - } }