Skip to content

Commit

Permalink
If the browse manga is initialized update everything otherwise only u…
Browse files Browse the repository at this point in the history
…pdate the title and thumbnail
  • Loading branch information
cuong-tran committed Nov 23, 2024
1 parent cb5025d commit 1c20292
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ class NetworkToLocalManga(
}
!localManga.favorite -> {
// if the manga isn't a favorite, update new info from source to db
val mangaUpdate = manga.toMangaUpdate().copy(
id = localManga.id,
thumbnailUrl = manga.thumbnailUrl?.takeUnless { it.isBlank() },
)
val newThumbnail = manga.thumbnailUrl?.takeUnless { it.isBlank() }
val mangaUpdate = if (manga.initialized) {
manga.toMangaUpdate().copy(
id = localManga.id,
thumbnailUrl = newThumbnail,
)
} else {
localManga.toMangaUpdate().copy(
title = manga.title,
thumbnailUrl = newThumbnail,
)
}
mangaRepository.update(mangaUpdate)
manga.copy(id = localManga.id)
}
Expand Down

0 comments on commit 1c20292

Please sign in to comment.