Skip to content

Commit

Permalink
Sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
andreespirela committed May 4, 2022
1 parent ea244bb commit 3300646
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fetchTokenById("ABC", (filterData) => filterData.type === "community").then(
### Fetching Paginated Items (Tokens | People)

**Signature**:
`fetchPaginated = async<T extends PaginatedToken | CommunityPeople>(type: "people" | "tokens", pageSize: number = 10, page: number = 1): Promise<PaginatedData<T>>`
`fetchPaginated = async<T extends PaginatedToken | CommunityPeople>(type: "people" | "tokens", pageSize: number = 10, page: number = 1, sort: boolean = false): Promise<PaginatedData<T>>`

**Usage**:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "verto-cache-interface",
"version": "1.2.2",
"version": "1.2.3",
"description": "A communication package with Verto Cache System",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/calls/fetch-paginated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {CommunityPeople} from "verto-internals/interfaces/contracts";
import {PaginatedToken} from "./types/token-metadata";
import {PaginatedData} from "verto-internals/services/miscellaneous/models";

export const fetchPaginated = async<T extends PaginatedToken | CommunityPeople>(type: "people" | "tokens", pageSize: number = 50, page: number = 1): Promise<PaginatedData<T>> => {
const data = (await cacheApiBaseRequest<PaginationResult>(`token/paginate?type=${type}&size=${pageSize}&page=${page}`))?.data;
export const fetchPaginated = async<T extends PaginatedToken | CommunityPeople>(type: "people" | "tokens", pageSize: number = 50, page: number = 1, sort = false): Promise<PaginatedData<T>> => {
const data = (await cacheApiBaseRequest<PaginationResult>(`token/paginate?type=${type}&size=${pageSize}&page=${page}${sort ? '&sort=true' : ''}`))?.data;
const paginationInfo = data?.paginationInfo || {
page: 0,
pageSize: 0,
Expand All @@ -20,7 +20,7 @@ export const fetchPaginated = async<T extends PaginatedToken | CommunityPeople>(
items: results,
hasNextPage: () => paginationInfo.maxPages > paginationInfo.page,
nextPage: () => {
return fetchPaginated(type, pageSize, page + 1)
return fetchPaginated(type, pageSize, page + 1, sort)
},
isEmpty: () => paginationInfo.found === 0,
getPaginationInfo: () => paginationInfo
Expand Down

0 comments on commit 3300646

Please sign in to comment.