refactor(persons): update all callers for the paged /api/persons response

GET /api/persons now returns PersonSearchResult { items, … } instead of a bare
list. Update every caller: the dashboard top-persons path reads .items; the
unused full-list fetches in documents/new and documents/[id]/edit are dropped
(both pages use the self-fetching PersonTypeahead); the raw-fetch consumers
(PersonTypeahead, PersonMultiSelect, PersonMentionEditor) read body.items and
pass review=true so search still spans the whole directory. Specs updated to
the new envelope shape.

Refs #667

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-27 13:56:00 +02:00
parent 9d859dcb05
commit 6c3552dc6a
9 changed files with 56 additions and 39 deletions

View File

@@ -52,7 +52,7 @@ export async function load({ fetch, parent }) {
await Promise.allSettled(readerFetches);
const readerStats = settled<StatsDTO>(statsRes);
const topPersons = settled<PersonSummaryDTO[]>(topPersonsRes) ?? [];
const topPersons = settled<{ items: PersonSummaryDTO[] }>(topPersonsRes)?.items ?? [];
const searchData = settled<{ items: { document: Document }[] }>(recentDocsRes);
const recentDocs = searchData?.items.map((i) => i.document) ?? [];
const recentStories = settled<Geschichte[]>(recentStoriesRes) ?? [];

View File

@@ -24,21 +24,16 @@ export async function load({
const { id } = params;
const api = createApiClient(fetch);
const [docResult, personsResult] = await Promise.all([
api.GET('/api/documents/{id}', { params: { path: { id } } }),
api.GET('/api/persons')
]);
const docResult = await api.GET('/api/documents/{id}', { params: { path: { id } } });
if (!docResult.response.ok) {
throw error(docResult.response.status, getErrorMessage(extractErrorCode(docResult.error)));
}
if (!personsResult.response.ok) {
throw error(personsResult.response.status, getErrorMessage('INTERNAL_ERROR'));
}
return {
document: docResult.data!,
persons: personsResult.data
// Sender/receiver editing uses PersonTypeahead (self-fetching); no full list is consumed.
persons: [] as never[]
};
}

View File

@@ -57,10 +57,12 @@ export async function load({
);
}
const [personsResult] = await Promise.all([api.GET('/api/persons'), ...requests]);
await Promise.all(requests);
return {
persons: personsResult.response.ok ? personsResult.data : [],
// Sender/receiver selection uses PersonTypeahead, which fetches its own results on
// demand — the page never consumes a pre-loaded full person list, so none is fetched.
persons: [] as never[],
initialSenderId: senderId,
initialSenderName,
initialReceivers