Skip to content

Commit

Permalink
inline manga update
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Nov 20, 2024
1 parent 896a930 commit eaa0944
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand All @@ -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() },
),
)
}
}

0 comments on commit eaa0944

Please sign in to comment.