Update non-library manga data when browsing (mihonapp/mihon#1967)

(cherry picked from commit a594ad392d4793f3a5cb2b709d29b2feab6120d3)
This commit is contained in:
AntsyLich 2025-04-07 12:10:12 +06:00 committed by Cuong-Tran
parent fa7b18590e
commit 5da873cac1
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
4 changed files with 27 additions and 10 deletions

View file

@ -21,6 +21,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
### Improved
- Significantly improve browsing speed (near instantaneous) ([@AntsyLich](https://github.com/AntsyLich)) ([#1946](https://github.com/mihonapp/mihon/pull/1946))
- Deduplicate entries when browsing ([@AntsyLich](https://github.com/AntsyLich)) ([#1957](https://github.com/mihonapp/mihon/pull/1957))
- Update non-library manga data when browsing ([@AntsyLich](https://github.com/AntsyLich)) ([#1967](https://github.com/mihonapp/mihon/pull/1967))
### Changed
- Display all similarly named duplicates in duplicate manga dialogue ([@NarwhalHorns](https://github.com/NarwhalHorns), [@AntsyLich](https://github.com/AntsyLich)) ([#1861](https://github.com/mihonapp/mihon/pull/1861))

View file

@ -123,13 +123,15 @@ class MangaRepositoryImpl(
mangasQueries.insertNetworkManga(
source = it.source,
url = it.url,
artist = it.artist,
author = it.author,
description = it.description,
genre = it.genre,
title = it.title,
status = it.status,
thumbnailUrl = it.thumbnailUrl,
// SY -->
title = it.ogTitle,
artist = it.ogArtist,
author = it.ogAuthor,
thumbnailUrl = it.ogThumbnailUrl,
description = it.ogDescription,
genre = it.ogGenre,
status = it.ogStatus,
// SY <--
favorite = it.favorite,
lastUpdate = it.lastUpdate,
nextUpdate = it.nextUpdate,
@ -141,6 +143,11 @@ class MangaRepositoryImpl(
dateAdded = it.dateAdded,
updateStrategy = it.updateStrategy,
version = it.version,
// SY -->
updateTitle = it.ogTitle.isNotBlank(),
updateCover = !it.ogThumbnailUrl.isNullOrBlank(),
// SY <--
updateDetails = it.initialized,
mapper = MangaMapper::mapManga,
)
.executeAsOne()

View file

@ -208,9 +208,18 @@ insertNetworkManga {
:updateStrategy, :calculateInterval, 0, :version
WHERE NOT EXISTS(SELECT 0 FROM mangas WHERE source = :source AND url = :url);
-- Update the title if it is not favorite
-- Update the relevant details if applicable and not favorite
UPDATE mangas
SET title = :title
SET
title = CASE WHEN :updateTitle THEN :title ELSE title END,
thumbnail_url = CASE WHEN :updateCover THEN :thumbnailUrl ELSE thumbnail_url END,
author = CASE WHEN :updateDetails THEN :author ELSE author END,
artist = CASE WHEN :updateDetails THEN :artist ELSE artist END,
description = CASE WHEN :updateDetails THEN :description ELSE description END,
genre = CASE WHEN :updateDetails THEN :genre ELSE genre END,
status = CASE WHEN :updateDetails THEN :status ELSE status END,
update_strategy = CASE WHEN :updateDetails THEN :updateStrategy ELSE update_strategy END,
initialized = :updateDetails
WHERE source = :source
AND url = :url
AND favorite = 0;

View file

@ -8,7 +8,7 @@ class NetworkToLocalManga(
) {
suspend operator fun invoke(manga: Manga): Manga {
return mangaRepository.insertNetworkManga(listOf(manga)).single()
return invoke(listOf(manga)).single()
}
suspend operator fun invoke(manga: List<Manga>): List<Manga> {