feat(playlists): integrate Navidrome smart playlist flow into playlists page

Move smart playlist creation and management into Playlists, including Navidrome-only gating, smart-name/icon presentation, and smarter refresh handling while server-side smart rules are being applied.
This commit is contained in:
Maxim Isaev
2026-04-24 16:41:17 +03:00
parent 1c761682f4
commit 27a59f6b23
8 changed files with 785 additions and 15 deletions
+25 -1
View File
@@ -499,6 +499,30 @@ export async function getRandomSongs(size = 50, genre?: string, timeout = 15000)
return data.randomSongs?.song ?? [];
}
export interface RandomSongsFilters {
size?: number;
genre?: string;
fromYear?: number;
toYear?: number;
}
/** Extended random song fetch with server-side year/genre filtering. */
export async function getRandomSongsFiltered(
filters: RandomSongsFilters,
timeout = 15000,
): Promise<SubsonicSong[]> {
const params: Record<string, string | number> = {
size: filters.size ?? 50,
_t: Date.now(),
...libraryFilterParams(),
};
if (filters.genre) params.genre = filters.genre;
if (typeof filters.fromYear === 'number') params.fromYear = filters.fromYear;
if (typeof filters.toYear === 'number') params.toYear = filters.toYear;
const data = await api<{ randomSongs: { song: SubsonicSong[] } }>('getRandomSongs.view', params, timeout);
return data.randomSongs?.song ?? [];
}
export async function getSong(id: string): Promise<SubsonicSong | null> {
try {
const data = await api<{ song: SubsonicSong }>('getSong.view', { id });
@@ -995,7 +1019,7 @@ export function buildDownloadUrl(id: string): string {
// ─── Playlists ────────────────────────────────────────────────
export async function getPlaylists(): Promise<SubsonicPlaylist[]> {
const data = await api<{ playlists: { playlist: SubsonicPlaylist[] } }>('getPlaylists.view');
const data = await api<{ playlists: { playlist: SubsonicPlaylist[] } }>('getPlaylists.view', { _t: Date.now() });
return data.playlists?.playlist ?? [];
}