From 8db5723da8671a7f6a94278c21467afc11c0d2fe Mon Sep 17 00:00:00 2001
From: Diego Mello <diegolmello@gmail.com>
Date: Mon, 15 Oct 2018 16:42:23 -0300
Subject: [PATCH] [FIX] DDP badge wasn't hiding on fast connections (#477)

---
 app/containers/ConnectionBadge.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/app/containers/ConnectionBadge.js b/app/containers/ConnectionBadge.js
index 99a186dc6..fdfbc7203 100644
--- a/app/containers/ConnectionBadge.js
+++ b/app/containers/ConnectionBadge.js
@@ -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) {
@@ -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,
-- 
GitLab