If the browse manga is initialized update everything otherwise only update the title and thumbnail

This commit is contained in:
Cuong-Tran 2024-11-23 21:36:40 +07:00
parent cb5025dd18
commit 1c202920be
No known key found for this signature in database
GPG Key ID: 733AA7624B9315C2

View File

@ -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(
val newThumbnail = manga.thumbnailUrl?.takeUnless { it.isBlank() }
val mangaUpdate = if (manga.initialized) {
manga.toMangaUpdate().copy(
id = localManga.id,
thumbnailUrl = manga.thumbnailUrl?.takeUnless { it.isBlank() },
thumbnailUrl = newThumbnail,
)
} else {
localManga.toMangaUpdate().copy(
title = manga.title,
thumbnailUrl = newThumbnail,
)
}
mangaRepository.update(mangaUpdate)
manga.copy(id = localManga.id)
}