Add relatedMangas to MangaScreenModel

This commit is contained in:
Cuong M. Tran 2024-04-25 11:25:02 +07:00
parent 4d3eeefb2c
commit 0df6a7fb09
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
3 changed files with 12 additions and 9 deletions

View file

@ -560,7 +560,7 @@ private fun MangaScreenSmallImpl(
}
// KMK -->
if (state.manga.relatedMangas!!.isNotEmpty()) {
if (state.relatedMangas?.isNotEmpty() == true) {
item(
key = MangaScreenItem.RELATED_TITLES,
contentType = MangaScreenItem.RELATED_TITLES,
@ -572,7 +572,7 @@ private fun MangaScreenSmallImpl(
onClick = { /* Should show a page with grid/list of all the related manga */ },
) {
RelatedMangas(
mangas = state.manga.relatedMangas!!,
mangas = state.relatedMangas,
getMangaState = { getMangaState(it) },
onClickManga = onRelatedMangaClick,
onLongClickManga = onRelatedMangaLongClick,
@ -918,7 +918,7 @@ fun MangaScreenLargeImpl(
),
) {
// KMK -->
if (state.manga.relatedMangas!!.isNotEmpty()) {
if (state.relatedMangas?.isNotEmpty() == true) {
item(
key = MangaScreenItem.RELATED_TITLES,
contentType = MangaScreenItem.RELATED_TITLES,
@ -930,7 +930,7 @@ fun MangaScreenLargeImpl(
onClick = { /* Should show a page with grid/list of all the related manga */ },
) {
RelatedMangas(
mangas = state.manga.relatedMangas!!,
mangas = state.relatedMangas,
getMangaState = { getMangaState(it) },
onClickManga = onRelatedMangaClick,
onLongClickManga = onRelatedMangaLongClick,

View file

@ -208,6 +208,11 @@ class MangaScreenModel(
private val filteredChapters: List<ChapterList.Item>?
get() = successState?.processedChapters
// KMK -->
private val relatedMangas: List<Manga>
get() = successState?.relatedMangas ?: emptyList()
// KMK <--
val chapterSwipeStartAction = libraryPreferences.swipeToEndAction().get()
val chapterSwipeEndAction = libraryPreferences.swipeToStartAction().get()
@ -1654,6 +1659,9 @@ class MangaScreenModel(
val alwaysShowReadingProgress: Boolean,
val previewsRowCount: Int,
// SY <--
// KMK -->
val relatedMangas: List<Manga>? = null,
// KMK <--
) : State {
val processedChapters by lazy {
chapters.applyFilters(manga).toList()

View file

@ -65,11 +65,6 @@ data class Manga(
get() = customMangaInfo?.status ?: ogStatus
// SY <--
// KMK -->
val relatedMangas: List<Manga>?
get() = listOf(this, this, this, this, this, this, this, this, this, this, this, this, this)
// KMK <--
val expectedNextUpdate: Instant?
get() = nextUpdate
.takeIf { status != SManga.COMPLETED.toLong() }