Skip to content

Commit 6b71181

Browse files
authored
fix: Build List: Items are not reloaded when deleting (#268)
1 parent cdfddc3 commit 6b71181

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components/BuildList/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const BuildList: FunctionComponent = () => {
6565
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
6666
const [menuBuild, setMenuBuild] = React.useState<Build | null>();
6767
const [newCiBuildId, setNewCiBuildId] = React.useState("");
68+
const [paginationPage, setPaginationPage] = React.useState(1);
6869

6970
const handleMenuClick = (
7071
event: React.MouseEvent<HTMLElement>,
@@ -92,8 +93,9 @@ const BuildList: FunctionComponent = () => {
9293
[navigate]
9394
);
9495

95-
const getBuildListCalback = React.useCallback(
96+
const handlePaginationChange = React.useCallback(
9697
(page: number) => {
98+
setPaginationPage(page);
9799
if (selectedProjectId) {
98100
buildDispatch({ type: "request" });
99101
buildsService
@@ -112,8 +114,8 @@ const BuildList: FunctionComponent = () => {
112114
);
113115

114116
React.useEffect(() => {
115-
getBuildListCalback(1);
116-
}, [getBuildListCalback]);
117+
handlePaginationChange(1);
118+
}, [handlePaginationChange]);
117119

118120
return (
119121
<React.Fragment>
@@ -195,8 +197,9 @@ const BuildList: FunctionComponent = () => {
195197
<Pagination
196198
size="small"
197199
defaultPage={1}
200+
page={paginationPage}
198201
count={Math.ceil(total / take)}
199-
onChange={(event, page) => getBuildListCalback(page)}
202+
onChange={(event, page) => handlePaginationChange(page)}
200203
/>
201204
</Grid>
202205
</Grid>
@@ -297,6 +300,9 @@ const BuildList: FunctionComponent = () => {
297300
variant: "success",
298301
}
299302
);
303+
})
304+
.then(() => handlePaginationChange(paginationPage))
305+
.then(() => {
300306
if (menuBuild.id === selectedBuild?.id) {
301307
selectBuildCalback();
302308
}

0 commit comments

Comments
 (0)