MM-17612 Fix fetch periodic status updates when re-connecting (#3101)
This commit is contained in:
parent
cdd7a54ef4
commit
eb314d714a
1 changed files with 8 additions and 4 deletions
|
|
@ -78,6 +78,7 @@ export default class NetworkIndicator extends PureComponent {
|
|||
|
||||
this.backgroundColor = new Animated.Value(0);
|
||||
this.firstRun = true;
|
||||
this.statusUpdates = false;
|
||||
|
||||
this.networkListener = networkConnectionListener(this.handleConnectionChange);
|
||||
}
|
||||
|
|
@ -138,7 +139,7 @@ export default class NetworkIndicator extends PureComponent {
|
|||
}
|
||||
|
||||
connect = (displayBar = false) => {
|
||||
const {connection} = this.props.actions;
|
||||
const {connection, startPeriodicStatusUpdates} = this.props.actions;
|
||||
clearTimeout(this.connectionRetryTimeout);
|
||||
|
||||
NetInfo.fetch().then(async ({isConnected}) => {
|
||||
|
|
@ -149,7 +150,9 @@ export default class NetworkIndicator extends PureComponent {
|
|||
this.serverReachable = serverReachable;
|
||||
|
||||
if (serverReachable) {
|
||||
this.statusUpdates = true;
|
||||
this.initializeWebSocket();
|
||||
startPeriodicStatusUpdates();
|
||||
} else {
|
||||
if (displayBar) {
|
||||
this.show();
|
||||
|
|
@ -220,9 +223,11 @@ export default class NetworkIndicator extends PureComponent {
|
|||
} = actions;
|
||||
|
||||
if (open) {
|
||||
this.statusUpdates = true;
|
||||
this.initializeWebSocket();
|
||||
startPeriodicStatusUpdates();
|
||||
} else {
|
||||
} else if (this.statusUpdates) {
|
||||
this.statusUpdates = false;
|
||||
closeWebSocket(true);
|
||||
stopPeriodicStatusUpdates();
|
||||
}
|
||||
|
|
@ -249,13 +254,12 @@ export default class NetworkIndicator extends PureComponent {
|
|||
};
|
||||
|
||||
handleConnectionChange = ({hasInternet, serverReachable}) => {
|
||||
const {connection, startPeriodicStatusUpdates} = this.props.actions;
|
||||
const {connection} = this.props.actions;
|
||||
|
||||
// On first run always initialize the WebSocket
|
||||
// if we have internet connection
|
||||
if (hasInternet && this.firstRun) {
|
||||
this.initializeWebSocket();
|
||||
startPeriodicStatusUpdates();
|
||||
this.firstRun = false;
|
||||
|
||||
// if the state of the internet connection was previously known to be false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue