Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Apr 17, 2020
1 parent 2d40913 commit ba23491
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<EmptyStateComponent
Expand Down

0 comments on commit ba23491

Please sign in to comment.