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:
@@ -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[]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user