Skip to content

Commit 3b1b845

Browse files
authored
checks if request is done loading before api call (#262)
Signed-off-by: Amit Galitzky <amgalitz@amazon.com>
1 parent b25860d commit 3b1b845

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

public/pages/DetectorDetail/containers/DetectorDetail.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ export const DetectorDetail = (props: DetectorDetailProps) => {
161161
core.notifications.toasts.addDanger('Error getting all indices');
162162
});
163163
};
164-
getInitialIndices();
164+
// only need to check if indices exist after detector finishes loading
165+
if (!isLoadingDetector) {
166+
getInitialIndices();
167+
}
165168
}, [detector]);
166169

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

0 commit comments

Comments
 (0)