Skip to content

Commit

Permalink
fix: use page number from response (#1413)
Browse files Browse the repository at this point in the history
This is to avoid the edge case where a page does not exist anymore after
deleting the visualization that was listed in it.

The page in the component state needs to be set to the page returned in
the response when it differs.

Unfortunately there is an extra request with the not existing page,
because until we get the response from the api we don't know if a page
has been removed or not as a consequence of deleting visualizations.
  • Loading branch information
edoardo authored Jan 25, 2023
1 parent 34f3708 commit b5523bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/OpenFileDialog/OpenFileDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export const OpenFileDialog = ({

const { loading, error, data, refetch } = useDataQuery(filesQuery, {
lazy: true,
onComplete: (response) => {
if (page !== response.files.pager.page) {
setPage(response.files.pager.page)
}
},
})

const resetFilters = () => {
Expand Down Expand Up @@ -420,7 +425,7 @@ export const OpenFileDialog = ({
0 && (
<div className="pagination-controls">
<PaginationControls
page={page}
page={data.files.pager.page}
pager={data.files.pager}
onPageChange={setPage}
/>
Expand Down

0 comments on commit b5523bf

Please sign in to comment.