Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline status log #41719

Merged
merged 13 commits into from
Jun 3, 2024
15 changes: 14 additions & 1 deletion src/libs/NetworkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ 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) => {
hayata-suenaga marked this conversation as resolved.
Show resolved Hide resolved
setOfflineStatus((state.isInternetReachable ?? false) === false);
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
Log.info(
`[NetworkStatus] The user is not under force offline, calling NetInfo.fetch, setting "offlineStatus" to ${
(state.isInternetReachable ?? false) === false
} with network state: ${JSON.stringify(state)}`,
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Log.info(
`[NetworkStatus] The user is not under force offline, calling NetInfo.fetch, setting "offlineStatus" to ${
(state.isInternetReachable ?? false) === false
} with network state: ${JSON.stringify(state)}`,
);

});
}
},
});
Expand Down Expand Up @@ -110,6 +118,11 @@ function subscribeToNetInfo(): void {
return;
}
setOfflineStatus((state.isInternetReachable ?? false) === false);
Log.info(
`[NetworkStatus] NetInfo.addEventListener event coming, setting "offlineStatus" to ${(state.isInternetReachable ?? false) === false} with network state: ${JSON.stringify(
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
state,
)}`,
);
let networkStatus;
if (!isBoolean(state.isInternetReachable)) {
networkStatus = CONST.NETWORK.NETWORK_STATUS.UNKNOWN;
Expand Down
Loading