Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libs/NetworkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
let shouldForceOffline = false;
let isPoorConnectionSimulated: boolean | undefined;
let connectionChanges: ConnectionChanges | undefined;

let isNetworkStatusInitialized = false;
// We do not depend on updates on the UI to determine the network status
// or the offline status, so we can use `connectWithoutView` here.
Onyx.connectWithoutView({
Expand All @@ -80,6 +80,8 @@
return;
}

isNetworkStatusInitialized = true;

simulatePoorConnection(network);

isPoorConnectionSimulated = !!network.shouldSimulatePoorConnection;
Expand Down Expand Up @@ -109,7 +111,7 @@
});

let accountID = 0;
Onyx.connect({

Check warning on line 114 in src/libs/NetworkConnection.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (session) => {
if (!session?.accountID) {
Expand Down Expand Up @@ -231,6 +233,10 @@
// Subscribe to the state change event via NetInfo so we can update
// whether a user has internet connectivity or not.
const unsubscribeNetInfo = NetInfo.addEventListener((state) => {
if (!isNetworkStatusInitialized) {
return;
}

Log.info('[NetworkConnection] NetInfo state change', false, {...state});
if (shouldForceOffline) {
Log.info('[NetworkConnection] Not setting offline status because shouldForceOffline = true');
Expand Down
Loading