mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Cleanup usage of NetworkToLocalManga
This commit is contained in:
parent
79e711efc2
commit
3aac1f3281
6 changed files with 21 additions and 9 deletions
|
@ -23,6 +23,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||
- 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))
|
||||
|
||||
### Other
|
||||
- Cleanup usage of `NetworkToLocalManga` ([@cuong-tran](https://github.com/cuong-tran)) ([#](https://github.com/mihonapp/mihon/pull/))
|
||||
|
||||
## [v0.17.0] - 2024-10-26
|
||||
### Added
|
||||
- Option to disable reader zoom out ([@Splintorien](https://github.com/Splintorien)) ([#302](https://github.com/mihonapp/mihon/pull/302))
|
||||
|
|
|
@ -113,9 +113,11 @@ class BrowseSourceScreenModel(
|
|||
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
|
||||
}.flow.map { pagingData ->
|
||||
pagingData.map {
|
||||
networkToLocalManga.await(it.toDomainManga(sourceId))
|
||||
val networkManga = it.toDomainManga(sourceId)
|
||||
networkToLocalManga.await(networkManga)
|
||||
.let { localManga -> getManga.subscribe(localManga.url, localManga.source) }
|
||||
.filterNotNull()
|
||||
.map { manga -> manga.shouldUseNetworkMangaInfo(networkManga) }
|
||||
.stateIn(ioCoroutineScope)
|
||||
}
|
||||
.filter { !hideInLibraryItems || !it.value.favorite }
|
||||
|
|
|
@ -166,7 +166,9 @@ abstract class SearchScreenModel(
|
|||
}
|
||||
|
||||
val titles = page.mangas.map {
|
||||
networkToLocalManga.await(it.toDomainManga(source.id))
|
||||
val networkManga = it.toDomainManga(source.id)
|
||||
networkToLocalManga.await(networkManga)
|
||||
.shouldUseNetworkMangaInfo(networkManga)
|
||||
}
|
||||
|
||||
if (isActive) {
|
||||
|
|
|
@ -74,8 +74,9 @@ class DeepLinkScreenModel(
|
|||
}
|
||||
|
||||
private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga {
|
||||
return getMangaByUrlAndSourceId.await(sManga.url, sourceId)
|
||||
?: networkToLocalManga.await(sManga.toDomainManga(sourceId))
|
||||
val networkManga = sManga.toDomainManga(sourceId)
|
||||
return networkToLocalManga.await(networkManga)
|
||||
.shouldUseNetworkMangaInfo(networkManga)
|
||||
}
|
||||
|
||||
sealed interface State {
|
||||
|
|
|
@ -14,11 +14,6 @@ class NetworkToLocalManga(
|
|||
val id = insertManga(manga)
|
||||
manga.copy(id = id!!)
|
||||
}
|
||||
!localManga.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
|
||||
localManga.copy(title = manga.title)
|
||||
}
|
||||
else -> {
|
||||
localManga
|
||||
}
|
||||
|
|
|
@ -72,6 +72,15 @@ 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
|
||||
|
|
Loading…
Reference in a new issue