mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
Enhance library item handling by adding isEmpty property and filtering out empty libraries from the HomeContent
This commit is contained in:
@@ -79,7 +79,8 @@ class HomePageViewModel @Inject constructor(
|
||||
val mappedLibraries = libraries.map {
|
||||
LibraryItem(
|
||||
name = it.name!!,
|
||||
id = it.id
|
||||
id = it.id,
|
||||
isEmpty = it.childCount!! == 0
|
||||
)
|
||||
}
|
||||
_libraries.value = mappedLibraries
|
||||
|
||||
@@ -40,7 +40,7 @@ fun HomeContent(
|
||||
)
|
||||
}
|
||||
items(
|
||||
items = libraries,
|
||||
items = libraries.filter { libraryContent[it.id]?.isEmpty() != true },
|
||||
key = { it.id }
|
||||
) { item ->
|
||||
LibraryPosterSection(
|
||||
|
||||
@@ -14,7 +14,8 @@ data class ContinueWatchingItem(
|
||||
|
||||
data class LibraryItem(
|
||||
val name: String,
|
||||
val id: UUID
|
||||
val id: UUID,
|
||||
val isEmpty: Boolean
|
||||
)
|
||||
|
||||
data class PosterItem(
|
||||
|
||||
@@ -8,9 +8,9 @@ import kotlinx.coroutines.flow.first
|
||||
import org.jellyfin.sdk.api.client.Response
|
||||
import org.jellyfin.sdk.api.client.extensions.authenticateUserByName
|
||||
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.userLibraryApi
|
||||
import org.jellyfin.sdk.api.client.extensions.userViewsApi
|
||||
import org.jellyfin.sdk.createJellyfin
|
||||
import org.jellyfin.sdk.model.ClientInfo
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
@@ -92,7 +92,10 @@ class JellyfinApiClient @Inject constructor(
|
||||
if (!ensureConfigured()) {
|
||||
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())
|
||||
return response.content.items
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user