Fix query and API bugs: 403 for non-owners, page bounds, lifecycle filters, cover fallback, race-safe inserts, async album delete

This commit is contained in:
2026-09-24 05:14:05 +02:00
parent ab388e6ad6
commit 0e3576922f
90 changed files with 2083 additions and 322 deletions
+22
View File
@@ -0,0 +1,22 @@
/** Largest page size the API accepts (`PageRequest.MaxPageSize` in the backend). */
export const API_MAX_PAGE_SIZE = 100;
type Page<T> = { items: T[]; hasNextPage: boolean };
/** Loads consecutive pages until the list ends or `maxItems` items were collected. */
export async function fetchAllPages<T>(
loadPage: (pageNumber: number, pageSize: number) => Promise<Page<T> | undefined>,
maxItems: number
): Promise<T[]> {
const items: T[] = [];
for (let pageNumber = 1; items.length < maxItems; pageNumber++) {
const page = await loadPage(pageNumber, API_MAX_PAGE_SIZE);
if (!page) break;
items.push(...page.items);
if (!page.hasNextPage) break;
}
return items.slice(0, maxItems);
}