Skip to content

Commit

Permalink
#484 removed code dublication
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Eremic committed Jul 21, 2016
1 parent 5b125e3 commit 72b523c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions client/lib/yourturn/src/notification-bar/notification-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ class NotificationBar extends React.Component {
if (!this.state.interval && notifications.length > 0) {
this.startInterval();
} else if (this.state.interval && notifications.length == 0) {
clearInterval(this.state.interval);
this.setState({
interval: false
});
this.stopInterval();
}
}

Expand All @@ -55,22 +52,26 @@ class NotificationBar extends React.Component {
const { notifications = [] } = this.props;
if (notifications.length > 0) {
this.startInterval();
this.setState({
interval
});
}
}

componentWillUnmount() {
this.stopInterval();
}

startInterval() {
let interval = setInterval(() => {
const interval = setInterval(() => {
this.props.dispatch(Actions.removeNotificationsOlderThan(5000));
}, 5000);
this.setState({
interval
});
}

componentWillUnmount() {
stopInterval() {
this.setState({
interval: false
});
clearInterval(this.state.interval);
}

Expand Down

0 comments on commit 72b523c

Please sign in to comment.