-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Display Route #25434
Merged
Merged
Display Route #25434
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
41a3590
Add GetRoute API command
thienlnam a0f270c
Add handling to fetch route
thienlnam e5c55cd
get display showing
thienlnam 92e4489
Add styling / update version
thienlnam 3a2f1a0
Add errorFields
thienlnam c3abd93
Prevent fetching while offline
thienlnam e03cd93
Fix proptype
thienlnam 4201756
Add error dot indicator and screen wrapper
thienlnam 1b9056c
Handle clearing errors when updating input
thienlnam 02529d3
Merge branch 'main' into jack-add-map-display-route
thienlnam 2c5a9f0
Update react-native-x-maps to 1.0.8
thienlnam a8fb1c7
Update DistanceRequest.js
thienlnam 0105c37
prevent looping of getRoute
thienlnam d67bba4
add waypoint validation
thienlnam c928bfd
update styling
thienlnam 1cc24c9
Prettier
thienlnam b33c36d
Update styles.js
thienlnam 2f3be36
Merge branch 'main' into jack-add-map-display-route
thienlnam d8cf419
Merge branch 'main' into jack-add-map-display-route
thienlnam 679872e
Update DistanceRequest.js
thienlnam 55b5a38
clear out existing routes
thienlnam f4a8fce
Update Transaction.js
thienlnam d6d9d74
Merge branch 'main' into jack-add-map-display-route
thienlnam 944241e
use previous ref
thienlnam 90b941e
lint
thienlnam 090ba17
Clear route on new waypoint
thienlnam b542085
style actually
thienlnam 9f4d3ab
Merge branch 'main' into jack-add-map-display-route
thienlnam e32aeb1
Merge branch 'main' into jack-add-map-display-route
thienlnam 0eeb47b
Move shouldFetchRoute to a constant
thienlnam 844ee72
Update DistanceRequest.js
thienlnam 2fe1326
update logic lol
thienlnam 4708446
adjust the check
thienlnam 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx'; | |
import lodashGet from 'lodash/get'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import * as CollectionUtils from '../CollectionUtils'; | ||
import * as API from '../API'; | ||
|
||
const allTransactions = {}; | ||
Onyx.connect({ | ||
|
@@ -47,6 +48,15 @@ function addStop(transactionID) { | |
[`waypoint${newLastIndex}`]: {}, | ||
}, | ||
}, | ||
|
||
// Clear the existing route so that we don't show an old route | ||
routes: { | ||
route0: { | ||
geometry: { | ||
coordinates: null, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -63,6 +73,19 @@ function saveWaypoint(transactionID, index, waypoint) { | |
[`waypoint${index}`]: waypoint, | ||
}, | ||
}, | ||
// Empty out errors when we're saving a new waypoint as this indicates the user is updating their input | ||
errorFields: { | ||
route: null, | ||
}, | ||
|
||
// Clear the existing route so that we don't show an old route | ||
routes: { | ||
route0: { | ||
geometry: { | ||
coordinates: null, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -96,8 +119,72 @@ function removeWaypoint(transactionID, currentIndex) { | |
...transaction.comment, | ||
waypoints: reIndexedWaypoints, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also clear the error when we are removing the waypoint as we do in |
||
// Clear the existing route so that we don't show an old route | ||
routes: { | ||
route0: { | ||
geometry: { | ||
coordinates: null, | ||
}, | ||
}, | ||
}, | ||
}; | ||
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, newTransaction); | ||
} | ||
|
||
export {addStop, createInitialWaypoints, saveWaypoint, removeWaypoint}; | ||
/** | ||
* Gets the route for a set of waypoints | ||
* Used so we can generate a map view of the provided waypoints | ||
* @param {String} transactionID | ||
* @param {Object} waypoints | ||
*/ | ||
function getRoute(transactionID, waypoints) { | ||
API.read( | ||
'GetRoute', | ||
{ | ||
transactionID, | ||
waypoints: JSON.stringify(waypoints), | ||
}, | ||
{ | ||
optimisticData: [ | ||
{ | ||
// Clears any potentially stale error messages from fetching the route | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, | ||
value: { | ||
comment: { | ||
isLoading: true, | ||
}, | ||
errorFields: { | ||
route: null, | ||
}, | ||
}, | ||
}, | ||
], | ||
// The route and failure are sent back via pusher in the BE, we are just clearing the loading state here | ||
successData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, | ||
value: { | ||
comment: { | ||
isLoading: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
failureData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, | ||
value: { | ||
comment: { | ||
isLoading: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
); | ||
} | ||
|
||
export {addStop, createInitialWaypoints, saveWaypoint, removeWaypoint, getRoute}; |
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.
Nested ScreenWrapper can cause extra padding. There should only be one ScreenWrapper component per page. This caused #26008.