From c24ffe8b11e17b3ee1eeede6cc3956a968bdb2e0 Mon Sep 17 00:00:00 2001 From: Dean Whillier Date: Tue, 12 Feb 2019 11:06:43 -0500 Subject: [PATCH] [MM 13720] Fix for "No internet connection" banner not always showing (#2563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add `opacity` to compopnent state … … to trigger render updates when the property changes. * Fix bug stopping app from updating connection status - if the app is opened when no internet connection is present, turning on the internet with the app open will not remove the `No internet connection` message. * style corrections --- .../network_indicator/network_indicator.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/components/network_indicator/network_indicator.js b/app/components/network_indicator/network_indicator.js index 6da18ce6e..c6b32600a 100644 --- a/app/components/network_indicator/network_indicator.js +++ b/app/components/network_indicator/network_indicator.js @@ -67,9 +67,12 @@ export default class NetworkIndicator extends PureComponent { constructor(props) { super(props); + this.state = { + opacity: 0, + }; + const navBar = this.getNavBarHeight(props.isLandscape); this.top = new Animated.Value(navBar - HEIGHT); - this.opacity = 0; this.clearNotificationTimeout = null; this.backgroundColor = new Animated.Value(0); @@ -179,7 +182,9 @@ export default class NetworkIndicator extends PureComponent { ), ]).start(() => { this.backgroundColor.setValue(0); - this.opacity = 0; + this.setState({ + opacity: 0, + }); }); }; @@ -251,7 +256,13 @@ export default class NetworkIndicator extends PureComponent { this.initializeWebSocket(); startPeriodicStatusUpdates(); this.firstRun = false; - return; + + // if the state of the internet connection was previously known to be false, + // don't exit connection handler in order for application to register it has + // reconnected to the internet + if (this.hasInternet !== false) { + return; + } } // Prevent for being called more than once. @@ -316,7 +327,9 @@ export default class NetworkIndicator extends PureComponent { }; show = () => { - this.opacity = 1; + this.setState({ + opacity: 1, + }); Animated.timing( this.top, { @@ -376,7 +389,7 @@ export default class NetworkIndicator extends PureComponent { } return ( - +