Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/libs/NetworkConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import * as NetworkActions from './actions/Network';
import CONFIG from '../CONFIG';
import CONST from '../CONST';

// NetInfo.addEventListener() returns a function used to unsubscribe the
// listener so we must create a reference to it and call it in stopListeningForReconnect()
let unsubscribeFromNetInfo;
let unsubscribeFromAppState;
let isOffline = false;
let hasPendingNetworkCheck = false;

Expand Down Expand Up @@ -67,7 +63,7 @@ function subscribeToNetInfo() {

// Subscribe to the state change event via NetInfo so we can update
// whether a user has internet connectivity or not.
unsubscribeFromNetInfo = NetInfo.addEventListener((state) => {
NetInfo.addEventListener((state) => {
Log.info('[NetworkConnection] NetInfo state change', false, state);
setOfflineStatus(state.isInternetReachable === false);
});
Expand All @@ -76,26 +72,11 @@ function subscribeToNetInfo() {
function listenForReconnect() {
Log.info('[NetworkConnection] listenForReconnect called');

unsubscribeFromAppState = AppStateMonitor.addBecameActiveListener(() => {
AppStateMonitor.addBecameActiveListener(() => {
triggerReconnectionCallbacks('app became active');
});
}

/**
* Tear down the event listeners when we are finished with them.
*/
function stopListeningForReconnect() {
Log.info('[NetworkConnection] stopListeningForReconnect called');
if (unsubscribeFromNetInfo) {
unsubscribeFromNetInfo();
unsubscribeFromNetInfo = undefined;
}
if (unsubscribeFromAppState) {
unsubscribeFromAppState();
unsubscribeFromAppState = undefined;
}
}

/**
* Register callback to fire when we reconnect
*
Expand Down Expand Up @@ -126,7 +107,6 @@ function recheckNetworkConnection() {
export default {
setOfflineStatus,
listenForReconnect,
stopListeningForReconnect,
onReconnect,
triggerReconnectionCallbacks,
recheckNetworkConnection,
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as Localize from '../../Localize';
import UnreadIndicatorUpdater from '../../UnreadIndicatorUpdater';
import Timers from '../../Timers';
import * as Pusher from '../../Pusher/pusher';
import NetworkConnection from '../../NetworkConnection';
import * as User from '../User';
import * as Authentication from '../../Authentication';
import * as Welcome from '../Welcome';
Expand Down Expand Up @@ -373,7 +372,6 @@ function clearSignInData() {
*/
function cleanupSession() {
// We got signed out in this tab or another so clean up any subscriptions and timers
NetworkConnection.stopListeningForReconnect();
UnreadIndicatorUpdater.stopListeningForReportChanges();
PushNotification.deregister();
PushNotification.clearNotifications();
Expand Down