Don't query for Live TV info if user does not have access (#286)

Fixes #281
This commit is contained in:
damontecres 2025-11-21 13:15:52 -05:00 committed by GitHub
parent 99e8b69c0e
commit ccc900cee7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 30 deletions

View file

@ -32,7 +32,6 @@ import kotlinx.coroutines.sync.withPermit
import kotlinx.coroutines.withContext
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.itemsApi
import org.jellyfin.sdk.api.client.extensions.liveTvApi
import org.jellyfin.sdk.api.client.extensions.tvShowsApi
import org.jellyfin.sdk.api.client.extensions.userLibraryApi
import org.jellyfin.sdk.api.client.extensions.userViewsApi
@ -219,33 +218,20 @@ class HomeViewModel
it.id in includedIds && it.id !in excluded &&
// Exclude Live TV because a recording folder view will be used instead
it.collectionType != CollectionType.LIVETV
}.mapNotNull { view ->
}.map { view ->
val title =
view.name?.let { context.getString(R.string.recently_added_in, it) }
?: context.getString(R.string.recently_added)
val viewId =
if (view.collectionType == CollectionType.LIVETV) {
api.liveTvApi
.getRecordingFolders(
userId = user.id,
).content.items
.firstOrNull()
?.id
} else {
view.id
}
viewId?.let {
val request =
GetLatestMediaRequest(
fields = SlimItemFields,
imageTypeLimit = 1,
parentId = viewId,
groupItems = true,
limit = limit,
isPlayed = null, // Server will handle user's preference
)
LatestData(title, request)
}
val request =
GetLatestMediaRequest(
fields = SlimItemFields,
imageTypeLimit = 1,
parentId = view.id,
groupItems = true,
limit = limit,
isPlayed = null, // Server will handle user's preference
)
LatestData(title, request)
}
return latestData