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:
damontecres 2025-11-13 18:40:52 -05:00 committed by GitHub
parent fe29b0cd88
commit 76b7a33328
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 8 deletions

View file

@ -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)

View file

@ -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) }
}
}

View file

@ -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) }
}
}

View file

@ -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,
),
)