Paginate address book contacts

This commit is contained in:
2026-07-30 05:22:09 +02:00
parent 1545ea711e
commit bf1d7c9678
7 changed files with 231 additions and 16 deletions
+12 -4
View File
@@ -168,8 +168,12 @@ type AddressListEntryListResponse = {
entries: AddressListEntry[];
};
type ContactListResponse = {
export type ContactListResponse = {
contacts: Contact[];
total: number;
offset: number;
limit: number;
has_more: boolean;
};
type AddressBookWriteTargetsResponse = {
@@ -588,11 +592,15 @@ export function resolveAddressSyncConflict(
});
}
export async function listContacts(settings: ApiSettings, options: {addressBookId?: string | null;query?: string | null;limit?: number;includeDeleted?: boolean;} = {}): Promise<Contact[]> {
const response = await apiFetch<ContactListResponse>(
export function listContactsPage(settings: ApiSettings, options: {addressBookId?: string | null;addressListId?: string | null;query?: string | null;limit?: number;offset?: number;includeDeleted?: boolean;} = {}): Promise<ContactListResponse> {
return apiFetch<ContactListResponse>(
settings,
`/api/v1/addresses/contacts${queryString({ address_book_id: options.addressBookId, query: options.query, limit: options.limit, include_deleted: options.includeDeleted ? "true" : null })}`
`/api/v1/addresses/contacts${queryString({ address_book_id: options.addressBookId, address_list_id: options.addressListId, query: options.query, limit: options.limit, offset: options.offset, include_deleted: options.includeDeleted ? "true" : null })}`
);
}
export async function listContacts(settings: ApiSettings, options: {addressBookId?: string | null;addressListId?: string | null;query?: string | null;limit?: number;offset?: number;includeDeleted?: boolean;} = {}): Promise<Contact[]> {
const response = await listContactsPage(settings, options);
return response.contacts;
}