Repository navigation
fix(tv): show mixed libraries in movie and series tabs #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Quick104
merged 8 commits into
Silo-Server:main
from
RXWatcher:fix/tv-mixed-library-scope
Oct 7, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5c06bc2
fix(tv): split mixed libraries between movie and series tabs
RXWatcher 2a1f49c
perf(tv): refill mixed shelves with bounded concurrency
RXWatcher fbba901
fix(tv): add retry action for partially loaded shelves
RXWatcher 828d3ac
perf(tv): skip refills for hidden featured shelves
RXWatcher 54baf4f
fix(tv): refill scoped shelves despite bounded inline counts
RXWatcher f3f3149
fix(tv): shuffle personal collections in their own scope, cancel supe…
RXWatcher e1b216e
fix(tv): offer no shuffle in Movies- or Series-scoped collection views
RXWatcher e0762c7
fix(tv): keep shuffle and refills within a mixed library's resolved s…
RXWatcher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...p/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/library/TvLibraryMediaScope.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package org.siloserver.silo.tv.ui.screens.library | ||
|
|
||
| import kotlinx.serialization.encodeToString | ||
| import org.siloserver.silo.model.catalog.CatalogResponse | ||
| import org.siloserver.silo.model.section.ResolvedSection | ||
| import org.siloserver.silo.model.section.SectionItem | ||
| import org.siloserver.silo.network.ApiResult | ||
| import org.siloserver.silo.network.SiloJson | ||
| import org.siloserver.silo.network.apiv2.CatalogContinuationV2 | ||
|
|
||
| internal fun matchesTvMediaScope(type: String, scope: String?): Boolean = when (scope) { | ||
| "movie" -> type.trim().lowercase() in setOf("movie", "movies", "film") | ||
| "series" -> type.trim().lowercase() in setOf("series", "show", "shows", "tv", "episode") | ||
| else -> true | ||
| } | ||
|
|
||
| internal data class ScopedTvSection(val section: ResolvedSection, val incomplete: Boolean = false) | ||
|
|
||
| /** Section sources reject type overlays. Page their original order and filter locally. */ | ||
| internal suspend fun scopeTvLibrarySection( | ||
| section: ResolvedSection, | ||
| mediaScope: String?, | ||
| loadPage: suspend (CatalogContinuationV2?) -> ApiResult<CatalogResponse>, | ||
| ): ScopedTvSection { | ||
| if (mediaScope == null) return ScopedTvSection(section) | ||
| val initial = section.items.filter { matchesTvMediaScope(it.type, mediaScope) } | ||
| val target = (section.itemLimit.takeIf { it > 0 } ?: section.items.size.coerceAtLeast(20)).coerceAtMost(100) | ||
| fun result(items: List<SectionItem>, incomplete: Boolean = false) = | ||
| ScopedTvSection(section.copy(items = items.take(target), totalCount = items.size.coerceAtMost(target)), incomplete) | ||
| // Inline total_count is not an exhaustion signal: several server shelves (e.g. recently added) | ||
| // report the bounded inline count. Only the catalog continuation can say nothing else remains. | ||
| if (initial.size >= target) return result(initial) | ||
| // The catalog section source pages the stored admin definition, not the profile-resolved one, so a | ||
| // customized or profile-added shelf cannot be refilled without dropping the profile's overrides. | ||
| if (section.customized || section.isCustom) return result(initial, incomplete = true) | ||
|
|
||
| val originals = section.items.associateBy { it.contentId } | ||
| val visible = linkedMapOf<String, SectionItem>() | ||
| var continuation: CatalogContinuationV2? = null | ||
| repeat(8) { | ||
| when (val page = loadPage(continuation)) { | ||
| is ApiResult.Success -> { | ||
| page.data.items.filter { matchesTvMediaScope(it.type, mediaScope) }.forEach { item -> | ||
| visible.putIfAbsent(item.contentId, originals[item.contentId] | ||
| ?: SiloJson.decodeFromString<SectionItem>(SiloJson.encodeToString(item))) | ||
| } | ||
| if (visible.size >= target || !page.data.hasMore) return result(visible.values.toList()) | ||
| val next = page.data.continuation | ||
| if (next == null || next === continuation || page.data.items.isEmpty()) | ||
| return result((visible.values + initial).distinctBy { it.contentId }, true) | ||
| continuation = next | ||
| } | ||
| else -> return result((visible.values + initial).distinctBy { it.contentId }, true) | ||
| } | ||
| } | ||
| return result((visible.values + initial).distinctBy { it.contentId }, true) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.