3
3
import React , { PureComponent } from 'react' ;
4
4
import type { Node , ComponentType } from 'react' ;
5
5
import { AppState , View } from 'react-native' ;
6
- import NetInfo from '@react-native-community/netinfo' ;
7
6
import * as ScreenOrientation from 'expo-screen-orientation' ;
8
7
9
8
import type { GlobalDispatch , Orientation as OrientationT } from '../types' ;
@@ -12,7 +11,7 @@ import { connectGlobal } from '../react-redux';
12
11
import { handleInitialNotification } from '../notification/notifOpen' ;
13
12
import NotificationListener from '../notification/NotificationListener' ;
14
13
import { ShareReceivedListener , handleInitialShare } from '../sharing' ;
15
- import { appOnline , appOrientation } from '../actions' ;
14
+ import { appOrientation } from '../actions' ;
16
15
import PresenceHeartbeat from '../presence/PresenceHeartbeat' ;
17
16
18
17
const styles = createStyleSheet ( {
@@ -50,9 +49,6 @@ const orientationLookup: OrientationLookup = {
50
49
} ;
51
50
52
51
class AppEventHandlersInner extends PureComponent < Props > {
53
- /** NetInfo disconnection callback. */
54
- netInfoDisconnectCallback : ( ( ) => void ) | null = null ;
55
-
56
52
handleOrientationChange = ( event : ScreenOrientation . OrientationChangeEvent ) => {
57
53
const { dispatch } = this . props ;
58
54
@@ -61,54 +57,6 @@ class AppEventHandlersInner extends PureComponent<Props> {
61
57
dispatch ( appOrientation ( orientationLookup [ orientation ] ) ) ;
62
58
} ;
63
59
64
- handleConnectivityChange = netInfoState => {
65
- const { dispatch } = this . props ;
66
-
67
- dispatch (
68
- appOnline (
69
- // From reading code at @react -native-community/net-info v6.0.0 (the
70
- // docs and types don't really give these answers):
71
- //
72
- // This will be `null` on both platforms while the first known value
73
- // of `true` or `false` is being shipped across the asynchronous RN
74
- // bridge.
75
- //
76
- // On Android, it shouldn't otherwise be `null`. The value is set to the
77
- // result of an Android function that only returns a boolean:
78
- // https://developer.android.com/reference/android/net/NetworkInfo#isConnected()
79
- //
80
- // On iOS, this can also be `null` while the app asynchronously
81
- // evaluates whether a network change should cause this to go from
82
- // `false` to `true`. Read on for details (gathered from
83
- // src/internal/internetReachability.ts in the library).
84
- //
85
- // 1. A request loop is started. A HEAD request is made to
86
- // https://clients3.google.com/generate_204, with a timeout of
87
- // 15s (`reachabilityRequestTimeout`), to see if the Internet is
88
- // reachable.
89
- // - If the `fetch` succeeds and a 204 is received, this will be
90
- // made `true`. We'll then sleep for 60s before making the
91
- // request again.
92
- // - If the `fetch` succeeds and a 204 is not received, or if the
93
- // fetch fails, or if the timeout expires, this will be made
94
- // `false`. We'll then sleep for only 5s before making the
95
- // request again.
96
- // 2. The request loop is interrupted if we get a
97
- // 'netInfo.networkStatusDidChange' event from the library's
98
- // native code, signaling a change in the network state. If that
99
- // change would make `netInfoState.type` become or remain
100
- // something good (i.e., not 'none' or 'unknown'), and this
101
- // (`.isInternetReachable`) is currently `false`, then this will
102
- // be made `null`, and the request loop described above will
103
- // start again.
104
- //
105
- // (Several of those parameters are configurable -- timeout durations,
106
- // URL, etc.)
107
- netInfoState . isInternetReachable ,
108
- ) ,
109
- ) ;
110
- } ;
111
-
112
60
notificationListener = new NotificationListener ( this . props . dispatch ) ;
113
61
shareListener = new ShareReceivedListener ( ) ;
114
62
@@ -121,13 +69,6 @@ class AppEventHandlersInner extends PureComponent<Props> {
121
69
dispatch ( handleInitialNotification ( ) ) ;
122
70
handleInitialShare ( ) ;
123
71
124
- NetInfo . configure ( {
125
- // This is the default, as of 6.0.0, but `OfflineNoticeProvider`
126
- // depends on this value being stable.
127
- reachabilityRequestTimeout : 15 * 1000 ,
128
- } ) ;
129
- this . netInfoDisconnectCallback = NetInfo . addEventListener ( this . handleConnectivityChange ) ;
130
-
131
72
AppState . addEventListener ( 'memoryWarning' , this . handleMemoryWarning ) ;
132
73
133
74
// The listener doesn't seem to fire in RN's "Debug with Chrome" mode.
@@ -138,10 +79,6 @@ class AppEventHandlersInner extends PureComponent<Props> {
138
79
}
139
80
140
81
componentWillUnmount ( ) {
141
- if ( this . netInfoDisconnectCallback ) {
142
- this . netInfoDisconnectCallback ( ) ;
143
- this . netInfoDisconnectCallback = null ;
144
- }
145
82
AppState . removeEventListener ( 'memoryWarning' , this . handleMemoryWarning ) ;
146
83
ScreenOrientation . removeOrientationChangeListeners ( ) ;
147
84
this . notificationListener . stop ( ) ;
0 commit comments