File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
src/components/common/hooks Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -33,4 +33,4 @@ export const FILE_READING_FAILED_STATUS = {
33
33
}
34
34
35
35
export const ONLINE_BANNER_TIMEOUT = 3000
36
- export const INTERNET_CONNECTIVITY_INTERVAL = 10000
36
+ export const INTERNET_CONNECTIVITY_INTERVAL = 20000
Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
18
18
abortControllerRef . current . abort ( )
19
19
}
20
20
21
+ const onConnectivitySuccess = ( ) => {
22
+ setOnline ( ( prev ) => {
23
+ if ( ! prev ) onOnline ( )
24
+ return true
25
+ } )
26
+ }
27
+
21
28
const checkConnectivity = async ( ) => {
22
29
if ( isAirgapped ) return
23
30
@@ -27,20 +34,13 @@ export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
27
34
28
35
try {
29
36
await getInternetConnectivity ( abortControllerRef . current )
30
- setOnline ( ( prev ) => {
31
- if ( ! prev ) {
32
- onOnline ( )
33
- }
34
- return true
35
- } )
37
+ onConnectivitySuccess ( )
38
+
36
39
timeoutRef . current = setTimeout ( checkConnectivity , INTERNET_CONNECTIVITY_INTERVAL )
37
40
} catch ( error ) {
38
41
try {
39
42
await getFallbackInternetConnectivity ( abortControllerRef . current )
40
- setOnline ( ( prev ) => {
41
- if ( ! prev ) onOnline ( )
42
- return true
43
- } )
43
+ onConnectivitySuccess ( )
44
44
} catch {
45
45
setOnline ( false )
46
46
} finally {
You can’t perform that action at this time.
0 commit comments