From 76b7a3332892f182bcf753252e7bda779376ba3e Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Thu, 13 Nov 2025 18:40:52 -0500 Subject: [PATCH] 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 --- .../wholphin/ui/components/RecommendedContent.kt | 2 +- .../wholphin/ui/components/RecommendedMovie.kt | 9 ++++++--- .../wholphin/ui/components/RecommendedTvShow.kt | 6 +++--- .../com/github/damontecres/wholphin/ui/main/HomePage.kt | 8 +++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt index 55e37c73..f2199333 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt @@ -42,7 +42,7 @@ abstract class RecommendedViewModel( ) : ViewModel() { abstract fun init() - abstract val rows: MutableStateFlow> + abstract val rows: MutableStateFlow> val loading = MutableLiveData(LoadingState.Loading) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedMovie.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedMovie.kt index 48388419..7eb676d0 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedMovie.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedMovie.kt @@ -57,13 +57,13 @@ class RecommendedMovieViewModel } override val rows = - MutableStateFlow>( + MutableStateFlow>( 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) } } } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedTvShow.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedTvShow.kt index f504c614..cf5580eb 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedTvShow.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedTvShow.kt @@ -59,13 +59,13 @@ class RecommendedTvShowViewModel } override val rows = - MutableStateFlow>( + MutableStateFlow>( 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) } } } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt index e73f0cb6..cf1fb36f 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt @@ -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, ), )