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(