fix(ui) - errors api call
This commit is contained in:
parent
94c80aec57
commit
31137dd001
2 changed files with 11 additions and 4 deletions
|
|
@ -18,7 +18,10 @@ class Notifications extends React.Component {
|
|||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
props.fetchList();
|
||||
setTimeout(() => {
|
||||
props.fetchList();
|
||||
}, 1000);
|
||||
|
||||
setInterval(() => {
|
||||
props.fetchList();
|
||||
}, AUTOREFRESH_INTERVAL);
|
||||
|
|
|
|||
|
|
@ -9,16 +9,19 @@ import {
|
|||
|
||||
const AUTOREFRESH_INTERVAL = 5 * 60 * 1000;
|
||||
const weekRange = getDateRangeFromValue(DATE_RANGE_VALUES.LAST_7_DAYS);
|
||||
let intervalId = null
|
||||
|
||||
function ErrorsBadge({ errorsStats = {}, fetchNewErrorsCount }) {
|
||||
function ErrorsBadge({ errorsStats = {}, fetchNewErrorsCount, projects }) {
|
||||
useEffect(() => {
|
||||
if (projects.size === 0 || !!intervalId) return;
|
||||
|
||||
const params = { startTimestamp: weekRange.start.unix() * 1000, endTimestamp: weekRange.end.unix() * 1000 };
|
||||
fetchNewErrorsCount(params)
|
||||
|
||||
setInterval(() => {
|
||||
intervalId = setInterval(() => {
|
||||
fetchNewErrorsCount(params);
|
||||
}, AUTOREFRESH_INTERVAL);
|
||||
}, [])
|
||||
}, [projects])
|
||||
|
||||
return errorsStats.unresolvedAndUnviewed > 0 ? (
|
||||
<div>{<div className={stl.badge} /> }</div>
|
||||
|
|
@ -27,4 +30,5 @@ function ErrorsBadge({ errorsStats = {}, fetchNewErrorsCount }) {
|
|||
|
||||
export default connect(state => ({
|
||||
errorsStats: state.getIn([ 'errors', 'stats' ]),
|
||||
projects: state.getIn([ 'site', 'list' ]),
|
||||
}), { fetchNewErrorsCount })(ErrorsBadge)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue