Skip to content
Snippets Groups Projects
Commit d77176bc authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

fix(autosave): fix timer on autosave indicator

parent 8ab0c3e6
No related branches found
No related tags found
1 merge request!43Sprint #19
...@@ -15,14 +15,22 @@ class AutosaveIndicator extends Component { ...@@ -15,14 +15,22 @@ class AutosaveIndicator extends Component {
this.timer = null this.timer = null
} }
componentDidMount() {
this.setTimer()
}
componentWillReceiveProps({ autosave: nextAutosave }) { componentWillReceiveProps({ autosave: nextAutosave }) {
const { autosave, toggleVisible } = this.props const { autosave, toggleVisible } = this.props
if (autosave && !isEqual(autosave, nextAutosave)) { if (!isEqual(autosave, nextAutosave)) {
toggleVisible() toggleVisible()
this.setTimer() this.setTimer()
} }
} }
componentWillUnmount() {
clearTimeout(this.timer)
}
setTimer = () => { setTimer = () => {
const { toggleVisible, delay = 2000 } = this.props const { toggleVisible, delay = 2000 } = this.props
if (this.timer) { if (this.timer) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment