Skip to content

Commit

Permalink
Merge pull request #41719 from nkdengineer/fix/40250
Browse files Browse the repository at this point in the history
Add offline status log
  • Loading branch information
Hayata Suenaga authored Jun 3, 2024
2 parents 161ad15 + 1178498 commit 053bd17
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libs/NetworkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ Onyx.connect({
shouldForceOffline = currentShouldForceOffline;
if (shouldForceOffline) {
setOfflineStatus(true);
Log.info(`[NetworkStatus] Setting "offlineStatus" to "true" because user is under force offline`);
} else {
// If we are no longer forcing offline fetch the NetInfo to set isOffline appropriately
NetInfo.fetch().then((state) => setOfflineStatus((state.isInternetReachable ?? false) === false));
NetInfo.fetch().then((state) => {
const isInternetReachable = Boolean(state.isInternetReachable);
setOfflineStatus(isInternetReachable);
Log.info(
`[NetworkStatus] The force-offline mode was turned off. Getting the device network status from NetInfo. Network state: ${JSON.stringify(
state,
)}. Setting the offline status to: ${isInternetReachable}.`,
);
});
}
},
});
Expand Down Expand Up @@ -151,6 +160,7 @@ function subscribeToNetworkStatus(): () => void {
return;
}
setOfflineStatus(state.isInternetReachable === false);
Log.info(`[NetworkStatus] NetInfo.addEventListener event coming, setting "offlineStatus" to ${Boolean(state.isInternetReachable)} with network state: ${JSON.stringify(state)}`);
setNetWorkStatus(state.isInternetReachable);
});

Expand Down

0 comments on commit 053bd17

Please sign in to comment.