From f4c602ef3fcd1fb8c9f944fbf8f6b369f0ed221e Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Fri, 28 Nov 2025 23:38:29 -0500 Subject: [PATCH] Fix broken scroll on home page (#345) Fixes an edge case on the home page where having at least two rows that don't have any latest items (such as collections or playlists) in between two regular libraries (as configured on your home profile settings) would prevent scrolling up from the second regular library --- .../damontecres/wholphin/ui/main/HomePage.kt | 17 ++++++++++++++- .../wholphin/ui/main/HomeViewModel.kt | 21 ++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) 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 d2575ef6..503c113b 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 @@ -1,6 +1,8 @@ package com.github.damontecres.wholphin.ui.main import android.widget.Toast +import androidx.compose.foundation.background +import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -326,9 +328,22 @@ fun HomePageContent( } is HomeRowLoadingState.Error -> { + var focused by remember { mutableStateOf(false) } Column( verticalArrangement = Arrangement.spacedBy(8.dp), - modifier = Modifier.animateItem(), + modifier = + Modifier + .onFocusChanged { + focused = it.isFocused + }.focusable() + .background( + if (focused) { + // Just so the user can tell it has focus + MaterialTheme.colorScheme.border.copy(alpha = .25f) + } else { + Color.Unspecified + }, + ).animateItem(), ) { Text( text = r.title, diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt index bd2b0453..834b0102 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt @@ -216,8 +216,7 @@ class HomeViewModel views.items .filter { it.id in includedIds && it.id !in excluded && - // Exclude Live TV because a recording folder view will be used instead - it.collectionType != CollectionType.LIVETV + it.collectionType in supportedLatestCollectionTypes }.map { view -> val title = view.name?.let { context.getString(R.string.recently_added_in, it) } @@ -239,17 +238,21 @@ class HomeViewModel private suspend fun loadLatest(latestData: List) { val rows = - latestData.map { (title, request) -> + latestData.mapNotNull { (title, request) -> try { val latest = api.userLibraryApi .getLatestMedia(request) .content .map { BaseItem.from(it, api, true) } - HomeRowLoadingState.Success( - title = title, - items = latest, - ) + if (latest.isNotEmpty()) { + HomeRowLoadingState.Success( + title = title, + items = latest, + ) + } else { + null + } } catch (ex: Exception) { Timber.e(ex, "Exception fetching %s", title) HomeRowLoadingState.Error( @@ -319,7 +322,9 @@ val supportedLatestCollectionTypes = setOf( CollectionType.MOVIES, CollectionType.TVSHOWS, - CollectionType.LIVETV, + CollectionType.HOMEVIDEOS, + // Exclude Live TV because a recording folder view will be used instead + null, // Recordings & mixed collection types ) data class LatestData(