Skip to content

Commit

Permalink
Merge pull request #43385 from Expensify/tgolen-ping-accountID
Browse files Browse the repository at this point in the history
Add user's accountID to the api/ping command
  • Loading branch information
dangrous authored Jun 13, 2024
2 parents f6de195 + c0b3c73 commit bce61c0
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit bce61c0

Please sign in to comment.