Skip to content

Commit

Permalink
[FIX] DDP badge wasn't hiding on fast connections (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Oct 15, 2018
1 parent cbf7a2e commit 315861e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/containers/ConnectionBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ class ConnectionBadge extends Component {
if (connecting || disconnected) {
this.animate(1);
}
this.timeout = setTimeout(() => {
const { connected } = this.props;
if (connected) {
this.timeout = setTimeout(() => {
this.animatedValue.stopAnimation();
this.animate(0);
}, 1000);
}
}, 1000);
}

componentDidUpdate(prevProps) {
Expand All @@ -73,17 +82,28 @@ class ConnectionBadge extends Component {

if ((connecting && connecting !== prevProps.connecting) || (disconnected && disconnected !== prevProps.disconnected)) {
if (!visible) {
this.animatedValue.stopAnimation();
this.animate(1);
}
} else if (connected && connected !== prevProps.connected) {
if (visible) {
setTimeout(() => {
if (this.timeout) {
clearTimeout(this.timeout);
}
this.timeout = setTimeout(() => {
this.animatedValue.stopAnimation();
this.animate(0);
}, 1000);
}
}
}

componentWillUnmount() {
if (this.timeout) {
clearTimeout(this.timeout);
}
}

animate = (toValue) => {
Animated.timing(
this.animatedValue,
Expand Down

0 comments on commit 315861e

Please sign in to comment.