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
This commit is contained in:
damontecres 2025-11-28 23:38:29 -05:00 committed by GitHub
parent ff91fa87e2
commit f4c602ef3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 9 deletions

View file

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

View file

@ -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<LatestData>) {
val rows =
latestData.map { (title, request) ->
latestData.mapNotNull { (title, request) ->
try {
val latest =
api.userLibraryApi
.getLatestMedia(request)
.content
.map { BaseItem.from(it, api, true) }
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(