[FIX] DDP badge wasn't hiding on fast connections (#477)
This commit is contained in:
parent
3502d4514b
commit
8db5723da8
|
@ -65,6 +65,15 @@ class ConnectionBadge extends Component {
|
||||||
if (connecting || disconnected) {
|
if (connecting || disconnected) {
|
||||||
this.animate(1);
|
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) {
|
componentDidUpdate(prevProps) {
|
||||||
|
@ -73,17 +82,28 @@ class ConnectionBadge extends Component {
|
||||||
|
|
||||||
if ((connecting && connecting !== prevProps.connecting) || (disconnected && disconnected !== prevProps.disconnected)) {
|
if ((connecting && connecting !== prevProps.connecting) || (disconnected && disconnected !== prevProps.disconnected)) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
|
this.animatedValue.stopAnimation();
|
||||||
this.animate(1);
|
this.animate(1);
|
||||||
}
|
}
|
||||||
} else if (connected && connected !== prevProps.connected) {
|
} else if (connected && connected !== prevProps.connected) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
setTimeout(() => {
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
}
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
this.animatedValue.stopAnimation();
|
||||||
this.animate(0);
|
this.animate(0);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
animate = (toValue) => {
|
animate = (toValue) => {
|
||||||
Animated.timing(
|
Animated.timing(
|
||||||
this.animatedValue,
|
this.animatedValue,
|
||||||
|
|
Loading…
Reference in New Issue