fix(Remote playback): kludge to scrub after stream move
This commit is contained in:
+14
-3
@@ -175,10 +175,20 @@ function createMusicStore() {
|
||||
const genres = await repo.getGenres(libraryId);
|
||||
if (genres.length === 0) return;
|
||||
|
||||
const hasCounts = genres.some(g => g.albumCount != null);
|
||||
// Counts are only *useful* if they actually differentiate genres. Some
|
||||
// servers return Fields=ItemCounts but populate every genre with the same
|
||||
// value (or 0), which leaves the list in its original alphabetical order
|
||||
// after "ranking" — so diversity selection seeds on the first genre and we
|
||||
// get a wall of A-genres ("avangard", "avan-gard", ...) with no Rock.
|
||||
// Treat that as "no usable counts" and fall through to the probe path,
|
||||
// which ranks by genres' real album counts instead.
|
||||
const positiveCounts = genres
|
||||
.map(g => g.albumCount)
|
||||
.filter((c): c is number => c != null && c > 0);
|
||||
const hasUsefulCounts = new Set(positiveCounts).size > 1;
|
||||
|
||||
let genreRows: GenreRow[];
|
||||
if (hasCounts) {
|
||||
if (hasUsefulCounts) {
|
||||
// Rank by reported count, pick a diverse subset, then fetch only those.
|
||||
const ranked = [...genres].sort(
|
||||
(a, b) => (b.albumCount ?? 0) - (a.albumCount ?? 0)
|
||||
@@ -188,7 +198,8 @@ function createMusicStore() {
|
||||
row => row.items.length > 0
|
||||
);
|
||||
} else {
|
||||
// No counts (offline, or a server that ignores Fields=ItemCounts).
|
||||
// No usable counts (offline, a server that ignores Fields=ItemCounts,
|
||||
// or one that returns uniform/zero counts — see hasUsefulCounts above).
|
||||
// The genre list is alphabetical, so probing the first N would only
|
||||
// ever surface A-genres. Sample at an even stride across the whole
|
||||
// list instead, so the probe pool spans A→Z; then drop empties, rank
|
||||
|
||||
Reference in New Issue
Block a user