Skip to content

Commit

Permalink
checks if request is done loading before api call (#262)
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
(cherry picked from commit 3b1b845)
  • Loading branch information
amitgalitz committed May 17, 2022
1 parent f9b1a5a commit 7cf172c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions public/pages/DetectorDetail/containers/DetectorDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ export const DetectorDetail = (props: DetectorDetailProps) => {
core.notifications.toasts.addDanger('Error getting all indices');
});
};
getInitialIndices();
// only need to check if indices exist after detector finishes loading
if (!isLoadingDetector) {
getInitialIndices();
}
}, [detector]);

useEffect(() => {
Expand All @@ -188,7 +191,7 @@ export const DetectorDetail = (props: DetectorDetailProps) => {
// If the detector state was changed after opening the stop detector modal,
// re-check if any jobs are running, and close the modal if it's not needed anymore
useEffect(() => {
if (!isRTJobRunning && !isHistoricalJobRunning) {
if (!isRTJobRunning && !isHistoricalJobRunning && !isEmpty(detector)) {
hideStopDetectorModal();
}
}, [detector]);
Expand Down

0 comments on commit 7cf172c

Please sign in to comment.