-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix distance still shows Pending when preview and report header already show distance #46165
Merged
neil-marcellini
merged 9 commits into
Expensify:main
from
bernhardoj:fix/43569-distance-still-shows-pending
Aug 2, 2024
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92e6708
clears routes when successfully created/updated transaction
bernhardoj 9591dbb
remove pending
bernhardoj d046c35
get distance in meters
bernhardoj 94eda7b
restructure the file to avoid cyclic deps
bernhardoj 67ae0cb
Merge branch 'main' into fix/43569-distance-still-shows-pending
bernhardoj 53e4b0d
add comment
bernhardoj 32f9a0d
Merge branch 'main' into fix/43569-distance-still-shows-pending
bernhardoj 9027edf
Merge branch 'main' into fix/43569-distance-still-shows-pending
bernhardoj 0cc4205
add comment
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
neil-marcellini marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import DistanceRequestUtils from '@libs/DistanceRequestUtils'; | ||
import type {OnyxInputOrEntry, Transaction} from '@src/types/onyx'; | ||
import type {Unit} from '@src/types/onyx/Policy'; | ||
|
||
function getDistanceInMeters(transaction: OnyxInputOrEntry<Transaction>, unit: Unit | undefined) { | ||
// If we are creating a new distance request, the distance is available in routes.route0.distance and it's already in meter. | ||
if (transaction?.routes?.route0?.distance) { | ||
return transaction.routes.route0.distance; | ||
} | ||
|
||
// If the request is completed, transaction.routes is cleared and comment.customUnit.quantity holds the new distance in the selected unit. | ||
// We need to convert it from the selected distance unit to meters. | ||
if (transaction?.comment?.customUnit?.quantity && unit) { | ||
return DistanceRequestUtils.convertToDistanceInMeters(transaction.comment.customUnit.quantity, unit); | ||
} | ||
return 0; | ||
} | ||
|
||
export default getDistanceInMeters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The distance logic here was updated in #43819 to fix #42959. The issue they face is actually the same as ours, which is the
transaction.comment.customUnit.quantity
value is in meters from GetRouteForDraft, but in the workspace unit when the request is completely created.I have retested the step from the linked PR and verify it still works as expected as in the linked PR.
web_2.mp4