mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-09 18:48:55 +01:00
Always update fresh data from source if manga isn't favorited
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.toMangaUpdate
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
class NetworkToLocalManga(
|
||||
@@ -14,6 +15,11 @@ class NetworkToLocalManga(
|
||||
val id = insertManga(manga)
|
||||
manga.copy(id = id!!)
|
||||
}
|
||||
!localManga.favorite -> {
|
||||
// if the manga isn't a favorite, update new info from source to db
|
||||
manga.updateManga(localManga.id)
|
||||
manga.copy(id = localManga.id)
|
||||
}
|
||||
else -> {
|
||||
localManga
|
||||
}
|
||||
@@ -27,4 +33,14 @@ 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() },
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,15 +72,6 @@ data class Manga(
|
||||
return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORT_DESC
|
||||
}
|
||||
|
||||
fun shouldUseNetworkMangaInfo(networkManga: Manga): Manga =
|
||||
if (!favorite) {
|
||||
// if the manga isn't a favorite, set its display title from source
|
||||
// if it later becomes a favorite, updated title will go to db
|
||||
copy(title = networkManga.title)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Generic filter that does not filter anything
|
||||
const val SHOW_ALL = 0x00000000L
|
||||
|
||||
Reference in New Issue
Block a user