Skip to content

fix: use ParentId per library instead of TopParentIds for mediabar - #51

Merged
RadicalMuffinMan merged 2 commits into
Moonfin-Client:masterfrom
enyineer:fix/mediabar-library-selection-and-shuffle
Mar 15, 2026
Merged

fix: use ParentId per library instead of TopParentIds for mediabar#51
RadicalMuffinMan merged 2 commits into
Moonfin-Client:masterfrom
enyineer:fix/mediabar-library-selection-and-shuffle

Conversation

@enyineer

Copy link
Copy Markdown
Contributor

Found another bug when selecting specific libraries, introduced by the TopParentIds usage.

The fix queries each selected library individually via ParentId, with OrderBy=Random + Limit at the DB level. Results are merged, shuffled for fair representation across libraries, then trimmed to the requested limit. At most limit + selectedLibraryCount items are held in memory (e.g. 13 items for limit=10 with 3 libraries).

This fixes the issue in my local testing.

TopParentIds filters on an internal DB column whose values differ
from the user-facing view GUIDs returned by getUserViews(). This
caused 0 results when specific libraries were selected.

Switch to per-library queries using ParentId (which matches view IDs),
each with OrderBy=Random and Limit for efficient DB-level random
selection without loading entire libraries into memory.

Also sets OrderBy=Random via reflection to avoid compile-time
reference to SortOrder which moved assemblies between 10.10 and 10.11.
TopParentIds filters on an internal DB column whose values differ
from the user-facing view GUIDs returned by getUserViews(). This
caused 0 results when specific libraries were selected.

Switch to per-library queries using ParentId (which matches view IDs),
each with OrderBy=Random and Limit for efficient DB-level random
selection without loading entire libraries into memory.

Also sets OrderBy=Random via reflection to avoid compile-time
reference to SortOrder which moved assemblies between 10.10 and 10.11.
@github-actions

github-actions Bot commented Mar 15, 2026

Copy link
Copy Markdown

✅ Build Successful

The plugin compiled successfully against .NET 8 / Jellyfin 10.10.0.

Property Value
Commit c5f292f
Workflow Build #21

@RadicalMuffinMan
RadicalMuffinMan merged commit 5ccdaaf into Moonfin-Client:master Mar 15, 2026
1 check passed
@enyineer
enyineer deleted the fix/mediabar-library-selection-and-shuffle branch March 15, 2026 10:32
// whose values differ from the user-facing view GUIDs.
var allItems = new List<BaseItem>();
var seenIds = new HashSet<Guid>();
var perLibraryLimit = Math.Max(1, limit / libraryIds.Count + 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda late, sorry, but is per library fairness really what you want?

example:
Library1 - 1000
Library2 - 250
Library3 - 20
Library4 - 10
Library5 - 5

Ideally Library1 should be represented the most. Right now you would have a lot of repeats from small libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants