Compare commits

2 Commits

Author SHA1 Message Date
108b53a7e2 refactor: use MaxPageSize constant as default pageSize across all frontend services
AlbumService.GetAlbumsAsync, AssetService.GetAssetsAsync, PersonService.GetAllAsync
now default to PagedParametersDto.MaxPageSize (250) instead of hardcoded 30.
Also fixed AssetService.GetAssetsAsync page default from 1 to 0 for consistency
with zero-based pagination.
2026-07-14 11:27:38 +02:00
38793efe6f fix(albums): use MaxPageSize constant for unassigned album fetch
Fixes #118 - hardcoded pageSize=999 exceeded server's MaxPageSize (250),
causing 400 Bad Request and the assign-album modal to hang on loading.
2026-07-14 11:24:34 +02:00
3 changed files with 8 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
using Butter.Dtos;
using Butter.Dtos.Album;
using Microsoft.Extensions.Options;
@@ -22,7 +23,7 @@ public sealed class AlbumService(
/// <param name="sortAsc">Whether to sort ascending. Default is <c>false</c> (descending).</param>
/// <param name="unassigned">When <c>true</c>, only return albums with no person assigned.</param>
/// <returns>A list of album previews, or null if the request failed.</returns>
public async Task<List<AlbumPreviewDto>?> GetAlbumsAsync(int page = 0, int pageSize = 30, string? search = null, string? sortBy = null, bool sortAsc = false, bool unassigned = false) {
public async Task<List<AlbumPreviewDto>?> GetAlbumsAsync(int page = 0, int pageSize = PagedParametersDto.MaxPageSize, string? search = null, string? sortBy = null, bool sortAsc = false, bool unassigned = false) {
var url = $"/api/album?page={page}&pageSize={pageSize}";
if (!string.IsNullOrEmpty(search))
url += $"&search={Uri.EscapeDataString(search)}";
@@ -58,8 +59,8 @@ public sealed class AlbumService(
/// Gets all albums that have no person assigned.
/// </summary>
/// <returns>A list of unassigned album previews, or null if the request failed.</returns>
public async Task<List<AlbumPreviewDto>?> GetUnassignedAsync() {
var response = await Client.GetAsync("/api/album?unassigned=true&pageSize=999");
public async Task<List<AlbumPreviewDto>?> GetUnassignedAsync(int pageSize = PagedParametersDto.MaxPageSize) {
var response = await Client.GetAsync($"/api/album?unassigned=true&pageSize={pageSize}");
if (response.IsSuccessStatusCode)
return await response.Content.ReadFromJsonAsync<List<AlbumPreviewDto>>();

View File

@@ -1,3 +1,4 @@
using Butter.Dtos;
using Butter.Dtos.Asset;
using Butter.Types;
using Microsoft.Extensions.Options;
@@ -23,7 +24,7 @@ public sealed class AssetService(
/// <param name="pageSize">The number of items per page.</param>
/// <returns>A list of asset previews, or null if the request failed.</returns>
public async Task<List<AssetPreviewDto>?> GetAssetsAsync(
EAssetType? type = null, bool random = true, Guid? seed = null, int page = 1, int pageSize = 30
EAssetType? type = null, bool random = true, Guid? seed = null, int page = 0, int pageSize = PagedParametersDto.MaxPageSize
) {
var url = $"/api/asset?page={page}&pageSize={pageSize}&random={random}";
if (type.HasValue)

View File

@@ -1,3 +1,4 @@
using Butter.Dtos;
using Butter.Dtos.Person;
using Microsoft.Extensions.Options;
@@ -21,7 +22,7 @@ public sealed class PersonService(
/// <param name="sortBy">Optional field to sort by (e.g. "name", "created", "albums").</param>
/// <param name="sortAsc">Whether to sort ascending. Default is <c>true</c>.</param>
/// <returns>A list of person previews, or null if the request failed.</returns>
public async Task<List<PersonPreviewDto>?> GetAllAsync(int page = 0, int pageSize = 30, string? search = null, string? sortBy = null, bool sortAsc = true) {
public async Task<List<PersonPreviewDto>?> GetAllAsync(int page = 0, int pageSize = PagedParametersDto.MaxPageSize, string? search = null, string? sortBy = null, bool sortAsc = true) {
var url = $"/api/person?page={page}&pageSize={pageSize}";
if (!string.IsNullOrEmpty(search))
url += $"&search={Uri.EscapeDataString(search)}";