Skip to content

Commit

Permalink
1098 superamin messes up dataset pagination (#1104)
Browse files Browse the repository at this point in the history
* “”

* ran pre-commit

* set page to 1 if superdmin mode chosen

* reverting this change

* i think this fixes 'mine' when superadmin is enabled

* use the current page num, only set on tab switch

* remove inline comments

* Update Explore.tsx

remove not used inline comment

---------

Co-authored-by: Chen Wang <[email protected]>
  • Loading branch information
tcnichol and longshuicy authored Jun 28, 2024
1 parent e5ed21e commit b000b8c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/src/components/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ export const Explore = (): JSX.Element => {

// Admin mode will fetch all datasets
useEffect(() => {
if (adminMode) listDatasets(0, limit, true);
else listDatasets((currPageNum - 1) * limit, limit, mine);
}, [adminMode, deletedDataset, mine, currPageNum, limit]);
if (adminMode) {
if (selectedTabIndex === 1) {
listDatasets((currPageNum - 1) * limit, limit, true);
} else {
listDatasets((currPageNum - 1) * limit, limit, false);
}
} else listDatasets((currPageNum - 1) * limit, limit, mine);
}, [adminMode, deletedDataset, mine, currPageNum, selectedTabIndex, limit]);

// switch tabs
const handleTabChange = (
Expand All @@ -61,11 +66,9 @@ export const Explore = (): JSX.Element => {
if (newTabIndex === 1) {
setMine(true);
setCurrPageNum(1);
listDatasets(0, limit, true);
} else {
setMine(false);
setCurrPageNum(1);
listDatasets(0, limit, false);
}
setSelectedTabIndex(newTabIndex);
};
Expand Down

0 comments on commit b000b8c

Please sign in to comment.