Skip to content

Commit

Permalink
fix: do not convert distance in case API call is not finished
Browse files Browse the repository at this point in the history
Signed-off-by: dominictb <tb-dominic@outlook.com>
  • Loading branch information
dominictb committed Jul 11, 2024
1 parent 654b8b4 commit ca8d718
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ function MoneyRequestConfirmationList({

const distance = useMemo(() => {
const value = TransactionUtils.getDistance(transaction);
if (isMovingTransactionFromTrackExpense && unit) {
if (canUseP2PDistanceRequests && isMovingTransactionFromTrackExpense && unit && !TransactionUtils.isFetchingWaypointsFromServer(transaction)) {
return DistanceRequestUtils.convertToDistanceInMeters(value, unit);
}
return value;
}, [isMovingTransactionFromTrackExpense, unit, transaction]);
}, [isMovingTransactionFromTrackExpense, unit, transaction, canUseP2PDistanceRequests]);
const prevDistance = usePrevious(distance);

const shouldCalculateDistanceAmount = isDistanceRequest && (iouAmount === 0 || prevRate !== rate || prevDistance !== distance);
Expand Down

0 comments on commit ca8d718

Please sign in to comment.