mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Fix two issues on recommended pages (#213)
Fix an issue where if there are no items for the "Continue Watching" row, the tab row would disappear Fix an issue where some rows (eg Recently released, recently added, suggestions, etc) on the recommended pages might never show up Fixes #207
This commit is contained in:
parent
fe29b0cd88
commit
76b7a33328
4 changed files with 17 additions and 8 deletions
|
|
@ -42,7 +42,7 @@ abstract class RecommendedViewModel(
|
|||
) : ViewModel() {
|
||||
abstract fun init()
|
||||
|
||||
abstract val rows: MutableStateFlow<MutableList<HomeRowLoadingState>>
|
||||
abstract val rows: MutableStateFlow<List<HomeRowLoadingState>>
|
||||
|
||||
val loading = MutableLiveData<LoadingState>(LoadingState.Loading)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ class RecommendedMovieViewModel
|
|||
}
|
||||
|
||||
override val rows =
|
||||
MutableStateFlow<MutableList<HomeRowLoadingState>>(
|
||||
MutableStateFlow<List<HomeRowLoadingState>>(
|
||||
rowTitles
|
||||
.map {
|
||||
HomeRowLoadingState.Pending(
|
||||
context.getString(it),
|
||||
)
|
||||
}.toMutableList(),
|
||||
},
|
||||
)
|
||||
|
||||
override fun init() {
|
||||
|
|
@ -166,6 +166,9 @@ class RecommendedMovieViewModel
|
|||
val result =
|
||||
try {
|
||||
pager.init()
|
||||
if (pager.isNotEmpty()) {
|
||||
pager.getBlocking(0)
|
||||
}
|
||||
HomeRowLoadingState.Success(title, pager)
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex, "Error fetching %s", title)
|
||||
|
|
@ -182,7 +185,7 @@ class RecommendedMovieViewModel
|
|||
row: HomeRowLoadingState,
|
||||
) {
|
||||
rows.update { current ->
|
||||
current.apply { set(position, row) }
|
||||
current.toMutableList().apply { set(position, row) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@ class RecommendedTvShowViewModel
|
|||
}
|
||||
|
||||
override val rows =
|
||||
MutableStateFlow<MutableList<HomeRowLoadingState>>(
|
||||
MutableStateFlow<List<HomeRowLoadingState>>(
|
||||
rowTitles
|
||||
.map {
|
||||
HomeRowLoadingState.Pending(
|
||||
context.getString(it),
|
||||
)
|
||||
}.toMutableList(),
|
||||
},
|
||||
)
|
||||
|
||||
override fun init() {
|
||||
|
|
@ -210,7 +210,7 @@ class RecommendedTvShowViewModel
|
|||
row: HomeRowLoadingState,
|
||||
) {
|
||||
rows.update { current ->
|
||||
current.apply { set(position, row) }
|
||||
current.toMutableList().apply { set(position, row) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -360,9 +360,15 @@ fun HomePageContent(
|
|||
),
|
||||
).onFocusChanged {
|
||||
if (it.isFocused) {
|
||||
val nonEmptyRowBefore =
|
||||
homeRows
|
||||
.subList(0, rowIndex)
|
||||
.count {
|
||||
it is HomeRowLoadingState.Success && it.items.isEmpty()
|
||||
}
|
||||
onFocusPosition?.invoke(
|
||||
RowColumn(
|
||||
rowIndex,
|
||||
rowIndex - nonEmptyRowBefore,
|
||||
index,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue