mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 03:23:45 +08:00
Add version to local copy of account and only re-render entire account if the version is different. Create an ElapsedTime component that re-renders on its own, and update SyncGraph to re-render on its own as well.
31 lines
624 B
JavaScript
31 lines
624 B
JavaScript
const React = window.React;
|
|
|
|
class ElapsedTime extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
elapsed: 0,
|
|
}
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.interval = setInterval(() => {
|
|
this.setState({elapsed: Date.now() - this.props.refTimestamp})
|
|
}, 1000);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
clearInterval(this.interval);
|
|
}
|
|
|
|
render() {
|
|
return <span>{this.props.formatTime(this.state.elapsed)} </span>
|
|
}
|
|
}
|
|
|
|
ElapsedTime.propTypes = {
|
|
refTimestamp: React.PropTypes.number, // milliseconds
|
|
formatTime: React.PropTypes.func,
|
|
}
|
|
|
|
window.ElapsedTime = ElapsedTime;
|