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

Only get GPS coordinates for scanned receipts #36062

Merged
merged 1 commit into from
Feb 9, 2024
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
47 changes: 27 additions & 20 deletions src/pages/iou/request/step/IOURequestStepConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,33 @@ function IOURequestStepConfirmation({
}

if (receiptFile) {
getCurrentPosition(
(successData) => {
requestMoney(selectedParticipants, trimmedComment, receiptFile, {
lat: successData.coords.latitude,
long: successData.coords.longitude,
});
},
(errorData) => {
Log.info('[IOURequestStepConfirmation] getCurrentPosition failed', false, errorData);
// When there is an error, the money can still be requested, it just won't include the GPS coordinates
requestMoney(selectedParticipants, trimmedComment, receiptFile);
},
{
// It's OK to get a cached location that is up to an hour old because the only accuracy needed is the country the user is in
maximumAge: 1000 * 60 * 60,

// 15 seconds, don't wait too long because the server can always fall back to using the IP address
timeout: 15000,
},
);
// If the transaction amount is zero, then the money is being requested through the "Scan" flow and the GPS coordinates need to be included.
if (transaction.amount === 0) {
getCurrentPosition(
(successData) => {
requestMoney(selectedParticipants, trimmedComment, receiptFile, {
lat: successData.coords.latitude,
long: successData.coords.longitude,
});
},
(errorData) => {
Log.info('[IOURequestStepConfirmation] getCurrentPosition failed', false, errorData);
// When there is an error, the money can still be requested, it just won't include the GPS coordinates
requestMoney(selectedParticipants, trimmedComment, receiptFile);
},
{
// It's OK to get a cached location that is up to an hour old because the only accuracy needed is the country the user is in
maximumAge: 1000 * 60 * 60,

// 15 seconds, don't wait too long because the server can always fall back to using the IP address
timeout: 15000,
},
);
return;
}

// Otherwise, the money is being requested through the "Manual" flow with an attached image and the GPS coordinates are not needed.
requestMoney(selectedParticipants, trimmedComment, receiptFile);
return;
}

Expand Down
Loading