Enhance library item handling by adding isEmpty property and filtering out empty libraries from the HomeContent

This commit is contained in:
2026-01-17 22:34:19 +01:00
parent 71080198c4
commit 6529b109f8
4 changed files with 10 additions and 5 deletions

View File

@@ -79,7 +79,8 @@ class HomePageViewModel @Inject constructor(
val mappedLibraries = libraries.map { val mappedLibraries = libraries.map {
LibraryItem( LibraryItem(
name = it.name!!, name = it.name!!,
id = it.id id = it.id,
isEmpty = it.childCount!! == 0
) )
} }
_libraries.value = mappedLibraries _libraries.value = mappedLibraries

View File

@@ -40,7 +40,7 @@ fun HomeContent(
) )
} }
items( items(
items = libraries, items = libraries.filter { libraryContent[it.id]?.isEmpty() != true },
key = { it.id } key = { it.id }
) { item -> ) { item ->
LibraryPosterSection( LibraryPosterSection(

View File

@@ -14,7 +14,8 @@ data class ContinueWatchingItem(
data class LibraryItem( data class LibraryItem(
val name: String, val name: String,
val id: UUID val id: UUID,
val isEmpty: Boolean
) )
data class PosterItem( data class PosterItem(

View File

@@ -8,9 +8,9 @@ import kotlinx.coroutines.flow.first
import org.jellyfin.sdk.api.client.Response import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.extensions.authenticateUserByName import org.jellyfin.sdk.api.client.extensions.authenticateUserByName
import org.jellyfin.sdk.api.client.extensions.itemsApi import org.jellyfin.sdk.api.client.extensions.itemsApi
import org.jellyfin.sdk.api.client.extensions.libraryApi
import org.jellyfin.sdk.api.client.extensions.userApi import org.jellyfin.sdk.api.client.extensions.userApi
import org.jellyfin.sdk.api.client.extensions.userLibraryApi import org.jellyfin.sdk.api.client.extensions.userLibraryApi
import org.jellyfin.sdk.api.client.extensions.userViewsApi
import org.jellyfin.sdk.createJellyfin import org.jellyfin.sdk.createJellyfin
import org.jellyfin.sdk.model.ClientInfo import org.jellyfin.sdk.model.ClientInfo
import org.jellyfin.sdk.model.api.BaseItemDto import org.jellyfin.sdk.model.api.BaseItemDto
@@ -92,7 +92,10 @@ class JellyfinApiClient @Inject constructor(
if (!ensureConfigured()) { if (!ensureConfigured()) {
return emptyList() return emptyList()
} }
val response = api.libraryApi.getMediaFolders(isHidden = false) val response = api.userViewsApi.getUserViews(
userId = getUserId(),
includeHidden = false
)
Log.d("getLibraries response: {}", response.content.toString()) Log.d("getLibraries response: {}", response.content.toString())
return response.content.items return response.content.items
} }