Skip live tv check if not in homesections

This commit is contained in:
Bill Thornton
2021-05-28 10:22:44 -04:00
parent 345dccf0d1
commit 9571182c1f

View File

@@ -110,24 +110,6 @@ class HomeFragment : StdBrowseFragment(), AudioEventListener {
// Update the views before creating rows
views = callApi<ItemsResult> { apiClient.GetUserViews(currentUser.id, it) }
// Check for live TV support
if (currentUser.policy.enableLiveTvAccess) {
// This is kind of ugly, but it mirrors how web handles the live TV rows on the home screen
// If we can retrieve one live TV recommendation, then we should display the rows
callApi<ItemsResult> {
apiClient.GetRecommendedLiveTvProgramsAsync(
RecommendedProgramQuery().apply {
userId = currentUser.id
enableTotalRecordCount = false
imageTypeLimit = 1
isAiring = true
limit = 1
},
it
)
}.let { includeLiveTvRows = !it.items.isNullOrEmpty() }
}
// Start out with default sections
val homesections = DEFAULT_SECTIONS.toMutableMap()
@@ -152,6 +134,24 @@ class HomeFragment : StdBrowseFragment(), AudioEventListener {
Timber.e(exception, "Unable to retrieve home sections")
}
// Check for live TV support
if (homesections.containsValue(HomeSectionType.LIVE_TV) && currentUser.policy.enableLiveTvAccess) {
// This is kind of ugly, but it mirrors how web handles the live TV rows on the home screen
// If we can retrieve one live TV recommendation, then we should display the rows
callApi<ItemsResult> {
apiClient.GetRecommendedLiveTvProgramsAsync(
RecommendedProgramQuery().apply {
userId = currentUser.id
enableTotalRecordCount = false
imageTypeLimit = 1
isAiring = true
limit = 1
},
it
)
}.let { includeLiveTvRows = !it.items.isNullOrEmpty() }
}
// Make sure the rows are empty
rows.clear()