Skip to content

Commit

Permalink
fix(examples): removed broken custom cursor code (#5757)
Browse files Browse the repository at this point in the history
In table-material-ui-cursor-pagination
Data provider was using the most recent date of any fetched data as an
"until" filter instead of paging, which caused both forward & backward
to go back in the Github API commit list.
  • Loading branch information
mkazin committed Mar 18, 2024
1 parent fedb191 commit 97b82a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { ICommit } from "../../interfaces";

export const PostList: React.FC = () => {
const [next, setNext] = React.useState<string | undefined>(undefined);
const { dataGridProps, tableQueryResult } = useDataGrid<ICommit>({
initialPageSize: 5,
metaData: {
cursor: {
next,
},
},
});

const { data } = tableQueryResult;
Expand Down Expand Up @@ -67,14 +61,6 @@ export const PostList: React.FC = () => {
<DataGrid
getRowId={(row) => row.sha}
{...dataGridProps}
onPaginationModelChange={(model, details) => {
const lastRow = data?.data[data.data.length - 1];
const next = lastRow?.commit.committer.date;
if (next) {
setNext(next);
}
dataGridProps.onPaginationModelChange?.(model, details);
}}
columns={columns}
autoHeight
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const dataProvider = (
getList: async ({ resource, metaData, pagination }) => {
let url = `${apiUrl}/${resource}?per_page=${pagination?.pageSize || 10}`;

if (metaData?.cursor?.next) {
url = `${url}&until=${metaData.cursor.next}`;
if (pagination?.current) {
url = `${url}&page=${pagination?.current}`;
}

const { data } = await httpClient.get(url);
Expand Down

0 comments on commit 97b82a0

Please sign in to comment.