From 1f2802ceea0ef948736afa98dc1c6115b0fc2b84 Mon Sep 17 00:00:00 2001 From: Dwynr Date: Fri, 14 Jun 2024 08:54:18 +0200 Subject: [PATCH] fix: reachability url --- index.js | 12 ++++++++++++ src/lib/services/isOnline/useNetworkInfo.ts | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 96bba038..0223665e 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,18 @@ import { decryptChatMessage } from "./src/lib/crypto" import { dbFs } from "./src/lib/db" import * as BackgroundFetch from "expo-background-fetch" import * as TaskManager from "expo-task-manager" +import NetInfo from "@react-native-community/netinfo" + +NetInfo.configure({ + reachabilityLongTimeout: 60000, + reachabilityShortTimeout: 15000, + reachabilityMethod: "GET", + reachabilityRequestTimeout: 30000, + reachabilityShouldRun: () => true, + reachabilityTest: async response => response.status === 200, + reachabilityUrl: "https://gateway.filen.io", + useNativeReachability: false +}) if (!__DEV__) { console.log = () => {} diff --git a/src/lib/services/isOnline/useNetworkInfo.ts b/src/lib/services/isOnline/useNetworkInfo.ts index df78a2be..f7a9c302 100644 --- a/src/lib/services/isOnline/useNetworkInfo.ts +++ b/src/lib/services/isOnline/useNetworkInfo.ts @@ -8,7 +8,7 @@ export type NetworkInfo = { wifi: boolean } -export const useNetworkInfo = () => { +export const useNetworkInfo = (): NetworkInfo => { const [state, setState] = useState({ online: true, wifi: true }) const update = useCallback(async () => { @@ -16,7 +16,7 @@ export const useNetworkInfo = () => { const s = await networkState() setState({ - online: s.isConnected && s.isInternetReachable, + online: s.isInternetReachable, wifi: s.type === Network.NetworkStateType.WIFI || s.type === Network.NetworkStateType.VPN || @@ -39,7 +39,7 @@ export const useNetworkInfo = () => { const removeNetInfoListener = NetInfo.addEventListener(s => { setState({ - online: s.isConnected && s.isInternetReachable, + online: s.isInternetReachable, wifi: s.type === NetInfoStateType.wifi || s.type === NetInfoStateType.vpn ||