diff --git a/src/libs/NetworkConnection.js b/src/libs/NetworkConnection.js index cd4d0b925ecc..972c3dcd5179 100644 --- a/src/libs/NetworkConnection.js +++ b/src/libs/NetworkConnection.js @@ -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; @@ -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); }); @@ -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 * @@ -126,7 +107,6 @@ function recheckNetworkConnection() { export default { setOfflineStatus, listenForReconnect, - stopListeningForReconnect, onReconnect, triggerReconnectionCallbacks, recheckNetworkConnection, diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index 54b221e8883b..13f1eadc5769 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -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'; @@ -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();