Skip to content

Commit

Permalink
Review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: brookewp <[email protected]>
  • Loading branch information
brookewp committed Feb 25, 2025
1 parent 1ec7391 commit 7a5ef2b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions inc/Validation/ConfigSchemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ private static function generate_http_query_config_schema(): array {
'pagination_schema' => Types::nullable(
Types::object( [
// This field provides an integer representing the total number of
// items available in paginated results. This field must be defined
// in order present to enable pagination support of any type,
// including cursor-based pagination.
// items available in paginated results. Either this field or
// `has_next_page` must be defined in order to enable
'total_items' => Types::nullable(
Types::object( [
'name' => Types::nullable( Types::string() ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function ItemList( props: ItemListProps ) {
onChangeView={ onChangeView }
paginationInfo={ {
totalItems: totalItems ?? data.length,
totalPages: totalPages ?? ( hasNextPage ? page + 1 : page - 1 ),
totalPages: totalPages ?? ( hasNextPage ? page + 1 : page - 1 ) ?? 1,
} }
search={ supportsSearch }
view={ view }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function usePaginationVariables( {
initialPerPage,
inputVariables,
}: UsePaginationVariablesInput ): UsePaginationVariables {
const [ paginationData, setPaginationData ] = useState< RemoteDataPagination >( {} );
const [ paginationData, setPaginationData ] = useState< RemoteDataPagination >();
const [ page, setPage ] = useState< number >( initialPage );
const [ perPage, setPerPage ] = useState< number | null >( initialPerPage ?? null );

Expand Down
2 changes: 1 addition & 1 deletion types/remote-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ interface InnerBlockContext {
}

interface RemoteDataPagination {
hasNextPage?: boolean;
cursorNext?: string;
cursorPrevious?: string;
hasNextPage?: boolean;
totalItems?: number;
}

Expand Down

0 comments on commit 7a5ef2b

Please sign in to comment.