mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-06 02:37:26 +01:00
Always update fresh data from source if manga isn't favorited
This commit is contained in:
parent
2b271579f3
commit
58b9613f4b
@ -22,9 +22,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
### Improved
|
### Improved
|
||||||
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
||||||
- Extension repo URLs are now auto-formatted ([@AntsyLich](https://github.com/AntsyLich), [@MajorTanya](https://github.com/MajorTanya))
|
- Extension repo URLs are now auto-formatted ([@AntsyLich](https://github.com/AntsyLich), [@MajorTanya](https://github.com/MajorTanya))
|
||||||
|
- Always update fresh data from source if manga isn't favorited ([@cuong-tran](https://github.com/cuong-tran)) ([#1435](https://github.com/mihonapp/mihon/pull/1435))
|
||||||
### Other
|
|
||||||
- Cleanup usage of `NetworkToLocalManga` ([@cuong-tran](https://github.com/cuong-tran)) ([#1435](https://github.com/mihonapp/mihon/pull/1435))
|
|
||||||
|
|
||||||
## [v0.17.0] - 2024-10-26
|
## [v0.17.0] - 2024-10-26
|
||||||
### Added
|
### Added
|
||||||
|
@ -113,11 +113,9 @@ class BrowseSourceScreenModel(
|
|||||||
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
|
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
|
||||||
}.flow.map { pagingData ->
|
}.flow.map { pagingData ->
|
||||||
pagingData.map {
|
pagingData.map {
|
||||||
val networkManga = it.toDomainManga(sourceId)
|
networkToLocalManga.await(it.toDomainManga(sourceId))
|
||||||
networkToLocalManga.await(networkManga)
|
|
||||||
.let { localManga -> getManga.subscribe(localManga.url, localManga.source) }
|
.let { localManga -> getManga.subscribe(localManga.url, localManga.source) }
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.map { manga -> manga.shouldUseNetworkMangaInfo(networkManga) }
|
|
||||||
.stateIn(ioCoroutineScope)
|
.stateIn(ioCoroutineScope)
|
||||||
}
|
}
|
||||||
.filter { !hideInLibraryItems || !it.value.favorite }
|
.filter { !hideInLibraryItems || !it.value.favorite }
|
||||||
|
@ -166,9 +166,7 @@ abstract class SearchScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val titles = page.mangas.map {
|
val titles = page.mangas.map {
|
||||||
val networkManga = it.toDomainManga(source.id)
|
networkToLocalManga.await(it.toDomainManga(source.id))
|
||||||
networkToLocalManga.await(networkManga)
|
|
||||||
.shouldUseNetworkMangaInfo(networkManga)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
|
@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.update
|
|||||||
import tachiyomi.core.common.util.lang.launchIO
|
import tachiyomi.core.common.util.lang.launchIO
|
||||||
import tachiyomi.domain.chapter.interactor.GetChapterByUrlAndMangaId
|
import tachiyomi.domain.chapter.interactor.GetChapterByUrlAndMangaId
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
import tachiyomi.domain.manga.interactor.GetMangaByUrlAndSourceId
|
|
||||||
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
@ -27,7 +26,6 @@ class DeepLinkScreenModel(
|
|||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
|
||||||
private val getChapterByUrlAndMangaId: GetChapterByUrlAndMangaId = Injekt.get(),
|
private val getChapterByUrlAndMangaId: GetChapterByUrlAndMangaId = Injekt.get(),
|
||||||
private val getMangaByUrlAndSourceId: GetMangaByUrlAndSourceId = Injekt.get(),
|
|
||||||
private val syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(),
|
private val syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(),
|
||||||
) : StateScreenModel<DeepLinkScreenModel.State>(State.Loading) {
|
) : StateScreenModel<DeepLinkScreenModel.State>(State.Loading) {
|
||||||
|
|
||||||
@ -74,9 +72,7 @@ class DeepLinkScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga {
|
private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga {
|
||||||
val networkManga = sManga.toDomainManga(sourceId)
|
return networkToLocalManga.await(sManga.toDomainManga(sourceId))
|
||||||
return networkToLocalManga.await(networkManga)
|
|
||||||
.shouldUseNetworkMangaInfo(networkManga)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface State {
|
sealed interface State {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tachiyomi.domain.manga.interactor
|
package tachiyomi.domain.manga.interactor
|
||||||
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
|
import tachiyomi.domain.manga.model.toMangaUpdate
|
||||||
import tachiyomi.domain.manga.repository.MangaRepository
|
import tachiyomi.domain.manga.repository.MangaRepository
|
||||||
|
|
||||||
class NetworkToLocalManga(
|
class NetworkToLocalManga(
|
||||||
@ -14,6 +15,11 @@ class NetworkToLocalManga(
|
|||||||
val id = insertManga(manga)
|
val id = insertManga(manga)
|
||||||
manga.copy(id = id!!)
|
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 -> {
|
else -> {
|
||||||
localManga
|
localManga
|
||||||
}
|
}
|
||||||
@ -27,4 +33,14 @@ class NetworkToLocalManga(
|
|||||||
private suspend fun insertManga(manga: Manga): Long? {
|
private suspend fun insertManga(manga: Manga): Long? {
|
||||||
return mangaRepository.insert(manga)
|
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
|
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 {
|
companion object {
|
||||||
// Generic filter that does not filter anything
|
// Generic filter that does not filter anything
|
||||||
const val SHOW_ALL = 0x00000000L
|
const val SHOW_ALL = 0x00000000L
|
||||||
|
Loading…
Reference in New Issue
Block a user