mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 11:30:28 +00:00
modify realtime component to work properly from componentWillReceiveProps
This commit is contained in:
parent
6f97341e42
commit
901e09bcac
@ -17,11 +17,11 @@ class Realtime extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
this.interval = window.setInterval(this.fetchData, 15000);
|
this.interval = window.setInterval(this.handleIntervalEvent, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearInterval(this.interval);
|
window.clearInterval(this.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(newProps, newState) {
|
componentWillReceiveProps(newProps, newState) {
|
||||||
@ -29,12 +29,11 @@ class Realtime extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchData()
|
this.fetchData(newProps.siteId)
|
||||||
}
|
}
|
||||||
|
|
||||||
paramsChanged(o, n) {
|
paramsChanged(o, n) {
|
||||||
|
return o.siteId != n.siteId;
|
||||||
return o.siteId != n.siteId || o.before != n.before || o.after != n.after;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
@ -45,8 +44,13 @@ class Realtime extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
fetchData() {
|
handleIntervalEvent() {
|
||||||
let url = `/sites/${this.props.siteId}/stats/site/realtime`
|
this.fetchData(this.props.siteId)
|
||||||
|
}
|
||||||
|
|
||||||
|
@bind
|
||||||
|
fetchData(siteId) {
|
||||||
|
let url = `/sites/${siteId}/stats/site/realtime`
|
||||||
Client.request(url)
|
Client.request(url)
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
this.setState({ count: d })
|
this.setState({ count: d })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user