Skip to content

Commit

Permalink
fix: reachability url
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Jun 14, 2024
1 parent 3248f7b commit 1f2802c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/services/isOnline/useNetworkInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export type NetworkInfo = {
wifi: boolean
}

export const useNetworkInfo = () => {
export const useNetworkInfo = (): NetworkInfo => {
const [state, setState] = useState<NetworkInfo>({ online: true, wifi: true })

const update = useCallback(async () => {
try {
const s = await networkState()

setState({
online: s.isConnected && s.isInternetReachable,
online: s.isInternetReachable,
wifi:
s.type === Network.NetworkStateType.WIFI ||
s.type === Network.NetworkStateType.VPN ||
Expand All @@ -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 ||
Expand Down

0 comments on commit 1f2802c

Please sign in to comment.