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
13 changes: 12 additions & 1 deletion src/libs/NetworkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ Onyx.connect({
},
});

let accountID = 0;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (session) => {
if (!session?.accountID) {
return;
}
accountID = session.accountID;
},
});

/**
* Set interval to periodically (re)check backend status.
* Because backend unreachability might imply lost internet connection, we need to check internet reachability.
Expand All @@ -107,7 +118,7 @@ function subscribeToBackendAndInternetReachability(): () => void {
return;
}
// Using the API url ensures reachability is tested over internet
fetch(`${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/Ping`, {
fetch(`${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/Ping?accountID=${accountID || 'unknown'}`, {
method: 'GET',
cache: 'no-cache',
})
Expand Down