mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Don't query for Live TV info if user does not have access (#286)
Fixes #281
This commit is contained in:
parent
99e8b69c0e
commit
ccc900cee7
2 changed files with 24 additions and 30 deletions
|
|
@ -27,16 +27,24 @@ class NavDrawerItemRepository
|
||||||
) {
|
) {
|
||||||
suspend fun getNavDrawerItems(): List<NavDrawerItem> {
|
suspend fun getNavDrawerItems(): List<NavDrawerItem> {
|
||||||
val user = serverRepository.currentUser.value
|
val user = serverRepository.currentUser.value
|
||||||
|
val tvAccess =
|
||||||
|
serverRepository.currentUserDto.value
|
||||||
|
?.policy
|
||||||
|
?.enableLiveTvAccess ?: false
|
||||||
val userViews =
|
val userViews =
|
||||||
api.userViewsApi
|
api.userViewsApi
|
||||||
.getUserViews(userId = user?.id)
|
.getUserViews(userId = user?.id)
|
||||||
.content.items
|
.content.items
|
||||||
val recordingFolders =
|
val recordingFolders =
|
||||||
api.liveTvApi
|
if (tvAccess) {
|
||||||
.getRecordingFolders(userId = user?.id)
|
api.liveTvApi
|
||||||
.content.items
|
.getRecordingFolders(userId = user?.id)
|
||||||
.map { it.id }
|
.content.items
|
||||||
.toSet()
|
.map { it.id }
|
||||||
|
.toSet()
|
||||||
|
} else {
|
||||||
|
setOf()
|
||||||
|
}
|
||||||
|
|
||||||
val builtins = listOf(NavDrawerItem.Favorites)
|
val builtins = listOf(NavDrawerItem.Favorites)
|
||||||
val libraries =
|
val libraries =
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import kotlinx.coroutines.sync.withPermit
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.jellyfin.sdk.api.client.ApiClient
|
import org.jellyfin.sdk.api.client.ApiClient
|
||||||
import org.jellyfin.sdk.api.client.extensions.itemsApi
|
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.tvShowsApi
|
||||||
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.api.client.extensions.userViewsApi
|
||||||
|
|
@ -219,33 +218,20 @@ class HomeViewModel
|
||||||
it.id in includedIds && it.id !in excluded &&
|
it.id in includedIds && it.id !in excluded &&
|
||||||
// Exclude Live TV because a recording folder view will be used instead
|
// Exclude Live TV because a recording folder view will be used instead
|
||||||
it.collectionType != CollectionType.LIVETV
|
it.collectionType != CollectionType.LIVETV
|
||||||
}.mapNotNull { view ->
|
}.map { view ->
|
||||||
val title =
|
val title =
|
||||||
view.name?.let { context.getString(R.string.recently_added_in, it) }
|
view.name?.let { context.getString(R.string.recently_added_in, it) }
|
||||||
?: context.getString(R.string.recently_added)
|
?: context.getString(R.string.recently_added)
|
||||||
val viewId =
|
val request =
|
||||||
if (view.collectionType == CollectionType.LIVETV) {
|
GetLatestMediaRequest(
|
||||||
api.liveTvApi
|
fields = SlimItemFields,
|
||||||
.getRecordingFolders(
|
imageTypeLimit = 1,
|
||||||
userId = user.id,
|
parentId = view.id,
|
||||||
).content.items
|
groupItems = true,
|
||||||
.firstOrNull()
|
limit = limit,
|
||||||
?.id
|
isPlayed = null, // Server will handle user's preference
|
||||||
} else {
|
)
|
||||||
view.id
|
LatestData(title, request)
|
||||||
}
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return latestData
|
return latestData
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue