diff --git a/app/services/contact_service.py b/app/services/contact_service.py index a2dc0c5..8eecf14 100644 --- a/app/services/contact_service.py +++ b/app/services/contact_service.py @@ -182,9 +182,9 @@ async def list_contacts( Contact.search_tsv.op("@@")(func.plainto_tsquery("german", search)) ) - # Keyset-Pagination: filter by cursor if provided - use_keyset = cursor is not None and sort_by == "id" and sort_order == "asc" - if use_keyset: + # Keyset-Pagination: use keyset when sorting by id (independent of cursor) + use_keyset = sort_by == "id" and sort_order == "asc" + if use_keyset and cursor is not None: base = base.where(Contact.id > uuid.UUID(cursor)) # Count