feat: add search/album/genre filtering and /albums + /genres browse pages

This commit is contained in:
daniel-c-harvey
2026-06-10 10:54:56 -04:00
parent 1071ba7374
commit 5cae83b9ed
24 changed files with 940 additions and 15 deletions
+49 -1
View File
@@ -20,7 +20,10 @@ public class TrackClient
int pageNumber,
int pageSize,
string? sortColumn = null,
bool sortDescending = false)
bool sortDescending = false,
string? searchText = null,
string? album = null,
string? genre = null)
{
var queryArgs = new Dictionary<string, string?>(){
["page"] = pageNumber.ToString(),
@@ -33,6 +36,15 @@ public class TrackClient
if (sortDescending)
queryArgs["sortDescending"] = "true";
if (!string.IsNullOrEmpty(searchText))
queryArgs["q"] = searchText;
if (!string.IsNullOrEmpty(album))
queryArgs["album"] = album;
if (!string.IsNullOrEmpty(genre))
queryArgs["genre"] = genre;
string query = QueryString.Create(queryArgs).ToString();
var response = await _http.GetAsync($"api/track/page{query}");
@@ -77,6 +89,42 @@ public class TrackClient
: ApiResult<TrackDto?>.CreateFailResult("Failed to deserialize response");
}
public async Task<ApiResult<List<AlbumSummaryDto>>> GetAlbums()
{
var response = await _http.GetAsync("api/track/albums");
if (!response.IsSuccessStatusCode)
return ApiResult<List<AlbumSummaryDto>>.CreateFailResult($"HTTP {(int)response.StatusCode}");
var json = await response.Content.ReadAsStringAsync();
var albums = JsonSerializer.Deserialize<List<AlbumSummaryDto>>(json, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return albums is not null
? ApiResult<List<AlbumSummaryDto>>.CreatePassResult(albums)
: ApiResult<List<AlbumSummaryDto>>.CreateFailResult("Failed to deserialize response");
}
public async Task<ApiResult<List<GenreSummaryDto>>> GetGenres()
{
var response = await _http.GetAsync("api/track/genres");
if (!response.IsSuccessStatusCode)
return ApiResult<List<GenreSummaryDto>>.CreateFailResult($"HTTP {(int)response.StatusCode}");
var json = await response.Content.ReadAsStringAsync();
var genres = JsonSerializer.Deserialize<List<GenreSummaryDto>>(json, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return genres is not null
? ApiResult<List<GenreSummaryDto>>.CreatePassResult(genres)
: ApiResult<List<GenreSummaryDto>>.CreateFailResult("Failed to deserialize response");
}
public async Task<ApiResult<TrackDto>> GetTrack(string entryKey)
{
var response = await _http.GetAsync($"api/track/meta/by-key/{Uri.EscapeDataString(entryKey)}");