mirror of
https://github.com/status-im/fathom.git
synced 2025-02-28 19:10:36 +00:00
when a new message is set, clear previous timeout
This commit is contained in:
parent
b5b31d89f8
commit
f6cab7c297
@ -10,6 +10,7 @@ class Notification extends Component {
|
|||||||
message: props.message,
|
message: props.message,
|
||||||
kind: props.kind || 'error'
|
kind: props.kind || 'error'
|
||||||
}
|
}
|
||||||
|
this.timeout = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
clearMessage() {
|
clearMessage() {
|
||||||
@ -19,7 +20,8 @@ class Notification extends Component {
|
|||||||
componentWillReceiveProps(newProps) {
|
componentWillReceiveProps(newProps) {
|
||||||
if(newProps.message != this.state.message) {
|
if(newProps.message != this.state.message) {
|
||||||
this.setState({ message: newProps.message, kind: newProps.kind || 'error' })
|
this.setState({ message: newProps.message, kind: newProps.kind || 'error' })
|
||||||
window.setTimeout(this.clearMessage.bind(this), 5000)
|
window.clearTimeout(this.timeout)
|
||||||
|
this.timeout = window.setTimeout(this.clearMessage.bind(this), 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user