mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-08 05:34:23 +08:00
Add other dashboard optimizations
Fix typo in Account's shouldComponentUpdate method Consolidate intervals into custom window events Manually update ElapsedTime contents
This commit is contained in:
parent
93942e792d
commit
971b64b4c2
3 changed files with 24 additions and 9 deletions
|
@ -42,7 +42,7 @@ class Account extends React.Component {
|
|||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
return nextProps.account.version !== this.props.account.version ||
|
||||
nextProps.active !== this.props.account.active ||
|
||||
nextProps.active !== this.props.active ||
|
||||
nextProps.assignment !== this.props.assignment ||
|
||||
nextProps.count !== this.props.count;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
const React = window.React;
|
||||
const ReactDOM = window.ReactDOM;
|
||||
|
||||
setInterval(() => {
|
||||
const event = new Event('tick');
|
||||
window.dispatchEvent(event);
|
||||
}, 1000);
|
||||
|
||||
class ElapsedTime extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -9,17 +15,20 @@ class ElapsedTime extends React.Component {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.interval = setInterval(() => {
|
||||
this.setState({elapsed: Date.now() - this.props.refTimestamp})
|
||||
}, 1000);
|
||||
this.onTick = () => {
|
||||
ReactDOM.findDOMNode(this.refs.timestamp).innerHTML = this.props.formatTime(
|
||||
Date.now() - this.props.refTimestamp
|
||||
);
|
||||
};
|
||||
window.addEventListener('tick', this.onTick);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.interval);
|
||||
window.removeEventListener('tick', this.onTick);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <span>{this.props.formatTime(this.state.elapsed)} </span>
|
||||
return <span ref="timestamp"></span>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
const React = window.React;
|
||||
const ReactDOM = window.ReactDOM;
|
||||
|
||||
setInterval(() => {
|
||||
const event = new Event('graphtick')
|
||||
window.dispatchEvent(event);
|
||||
}, 10000);
|
||||
|
||||
class SyncGraph extends React.Component {
|
||||
componentDidMount() {
|
||||
this.drawGraph(true);
|
||||
|
||||
this.interval = setInterval(() => {
|
||||
this.onGraphTick = () => {
|
||||
if (Date.now() - this.props.syncTimestamps[0] > 10000) {
|
||||
this.drawGraph(false);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
window.addEventListener('graphtick', this.onGraphTick);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
|
@ -17,7 +23,7 @@ class SyncGraph extends React.Component {
|
|||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.interval);
|
||||
window.removeEventListener('graphtick', this.onGraphTick);
|
||||
}
|
||||
|
||||
drawGraph(isInitial) {
|
||||
|
|
Loading…
Add table
Reference in a new issue