Skip to content

Commit 36bda48

Browse files
committed
refactor view reload function to be passed as props to switch branch component
1 parent 9e8c597 commit 36bda48

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ui/src/Components/DashBoard/Repository/RepoComponents/RepoDetails/RepoDetailBackdrop/SwitchBranchComponent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default function SwitchBranchComponent({
66
repoId,
77
branchName,
88
closeBackdrop,
9+
switchReloadView,
910
}) {
1011
const [branchError, setBranchError] = useState(false);
1112

@@ -23,6 +24,7 @@ export default function SwitchBranchComponent({
2324
})
2425
.then((res) => {
2526
if (res.data.data && !res.data.error) {
27+
switchReloadView();
2628
closeBackdrop(true);
2729
}
2830
})
@@ -31,7 +33,7 @@ export default function SwitchBranchComponent({
3133
setBranchError(true);
3234
}
3335
});
34-
}, [branchName, closeBackdrop, repoId]);
36+
}, [branchName, closeBackdrop, repoId, switchReloadView]);
3537

3638
return (
3739
<div className="xl:w-3/4 lg:w-3/4 md:w-11/12 sm:w-11/12 repo-backdrop--switchbranch">

ui/src/Components/DashBoard/Repository/RepoComponents/RepoDetails/RepositoryDetails.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export default function RepositoryDetails(props) {
8585
repoId={repoIdState}
8686
branchName={selectedBranch}
8787
closeBackdrop={closeBackdrop}
88+
switchReloadView={() => {
89+
setReloadView(true);
90+
}}
8891
></SwitchBranchComponent>
8992
);
9093
}, [repoIdState, selectedBranch]);
@@ -185,7 +188,6 @@ export default function RepositoryDetails(props) {
185188
setBackdropToggle(true);
186189
setAction("switchbranch");
187190
setSelectedBranch(branchName);
188-
setReloadView(true);
189191
};
190192

191193
const actionComponentPicker = () => {

0 commit comments

Comments
 (0)