feat(ratings): skip-to-1★ threshold and mix min-rating filter

Add Ratings section under General: manual skip count before setting 1★,
and per-axis minimum stars for random mixes/albums (song, album, artist).
StarRating shows five stars with selection capped at three; shared max in authStore.
Queue filtering via passesMixMinRatings; OpenSubsonic-style entity rating fields on types.
This commit is contained in:
Maxim Isaev
2026-04-08 02:39:25 +03:00
parent 705c80ef07
commit 8a1d942128
15 changed files with 418 additions and 37 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { SubsonicSong } from '../api/subsonic';
export interface MixMinRatingsConfig {
enabled: boolean;
minSong: number;
minAlbum: number;
minArtist: number;
}
/**
* Random (and future album) flows: drop songs that are below per-axis thresholds when enabled.
* Song axis uses `userRating` (missing = 0). Album/artist use optional OpenSubsonic-style
* fields on the song payload; if a threshold is positive but the value is absent, the song is kept.
*/
export function passesMixMinRatings(song: SubsonicSong, c: MixMinRatingsConfig): boolean {
if (!c.enabled) return true;
if (c.minSong > 0 && (song.userRating ?? 0) < c.minSong) return false;
if (c.minAlbum > 0) {
const r = song.albumUserRating;
if (r !== undefined && r < c.minAlbum) return false;
}
if (c.minArtist > 0) {
const r = song.artistUserRating;
if (r !== undefined && r < c.minArtist) return false;
}
return true;
}