From ba23491a1e3ae90c856eb8356a32fe3245ff41f5 Mon Sep 17 00:00:00 2001 From: shahzad Date: Fri, 17 Apr 2020 18:27:38 +0200 Subject: [PATCH] updated code --- .../connected/empty_state/empty_state.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx index e3d7ef0f009cf..09f687bda990d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx @@ -15,17 +15,24 @@ import { getDynamicSettings } from '../../../state/actions/dynamic_settings'; export const EmptyState: React.FC = ({ children }) => { const { data, loading, error } = useSelector(indexStatusSelector); const { lastRefresh } = useContext(UptimeRefreshContext); + const { settings } = useSelector(selectDynamicSettings); + const heartbeatIndices = settings?.heartbeatIndices || ''; + const dispatch = useDispatch(); useEffect(() => { - dispatch(getDynamicSettings()); - }, [dispatch]); + if (!data || data?.docCount === 0 || data?.indexExists === false) { + dispatch(indexStatusAction.get()); + } + // Don't add data , it will create endless loop + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dispatch, lastRefresh]); useEffect(() => { dispatch(indexStatusAction.get()); - }, [dispatch, lastRefresh]); + }, [dispatch, heartbeatIndices]); return (