-
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 - Unable to save distance when Start and Stop waypoints are valid address #52736
base: main
Are you sure you want to change the base?
Fix: Distance - Unable to save distance when Start and Stop waypoints are valid address #52736
Conversation
…x/48401-unable-save-waypoint-on-error
…x/48401-unable-save-waypoint-on-error
…x/48401-unable-save-waypoint-on-error
… re-used for invalid waypoints case
…x/48401-unable-save-waypoint-on-error
…x/48401-unable-save-waypoint-on-error
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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.
Screenshots/Videos
Android: Native
iOS: Native
Screen.Recording.2024-11-20.at.19.08.01.mov
Screen.Recording.2024-11-20.at.19.09.38.mov
iOS: mWeb Safari
Screen.Recording.2024-11-20.at.19.21.35.mov
MacOS: Chrome / Safari
Screen.Recording.2024-11-20.at.18.43.53.mov
Screen.Recording.2024-11-20.at.18.51.10.mov
MacOS: Desktop
Screen.Recording.2024-11-20.at.19.24.41.mov
@wildan-m I can still reproduce the error in offline mode. Even though, valid waypoints are shown, waypoint error is shown. Screen.Recording.2024-11-20.at.19.37.21.mov |
The other issue is even when error is shown, user is allowed to save the waypoints when offline. Screen.Recording.2024-11-20.at.19.24.41.mov |
@sobitneupane Thank you for the feedback. I couldn't address the offline issues with the current solution, but I believe I have a better solution now. This new solution will clear the distanceErrors as soon as server restore the waypoints to their previous correct values Please check this new Alternative 2 solution #48401 (comment) What do you think? |
Thanks for the update @wildan-m I have not tested your solution yet, but my initial thought is that it would be more efficient to clear the error when we open the MoneyRequestView page, if required, rather than iterating on each update. |
@sobitneupane any suggestion to improve current solution? I couldn't figured out one yet for the offline case, because there is no way we can server validate the transaction and transactionBackup while it's offline. IMO that x button in the moneyrequest view should be sufficient to handle that case |
Or we might also need to provide x button in the distance editor? |
…x/48401-unable-save-waypoint-on-error
@sobitneupane Hi, I've got an idea, while offline we can clear the error if all of the routes is a server validate route
useEffect(() => {
if(isOffline && hasRouteError && isDistanceRequest && isInitialMount){
const waypointValues = Object.values(waypoints || {});
const allWaypointsServerValidated = waypointValues.every(waypoint => waypoint.lat !== 0 && waypoint.lng !== 0 && waypoint.name);
if (allWaypointsServerValidated) {
TransactionAction.clearError(transaction.transactionID);
}
return;
}
if (isOffline || !shouldFetchRoute || !transaction?.transactionID) {
return;
}
TransactionAction.getRoute(transaction.transactionID, validatedWaypoints, transactionState);
setIsInitialMount(false);
}, [shouldFetchRoute, transaction?.transactionID, validatedWaypoints, isOffline, action, transactionState]); Note This will also clear error related to route exceeded when offline, we can't validate the route when offline even when all of the waypoints are valid address. Testing it..., please let me know if you have any concerns |
@sobitneupane I think it's working. The PR has been updated |
@sobitneupane additional update: we should also modify clearError to accept transactionState so the error message won't reappear when navigating back without saving in the distance editor. function clearError(transactionID: string, transactionState: TransactionState = CONST.TRANSACTION.STATE.CURRENT) {
let keyPrefix;
switch (transactionState) {
case CONST.TRANSACTION.STATE.DRAFT:
keyPrefix = ONYXKEYS.COLLECTION.TRANSACTION_DRAFT;
break;
case CONST.TRANSACTION.STATE.BACKUP:
keyPrefix = ONYXKEYS.COLLECTION.TRANSACTION_BACKUP;
break;
case CONST.TRANSACTION.STATE.CURRENT:
default:
keyPrefix = ONYXKEYS.COLLECTION.TRANSACTION;
break;
}
Onyx.merge(`${keyPrefix}${transactionID}`, {errors: null, errorFields: {route: null}});
}
|
Thanks for the update @wildan-m I am not sure if we are heading in the right direction. I believe we can have a solution much simpler than this. I will let you know once I thoroughly go through it. |
@wildan-m Can you please explain this change? Why do we need it and what are we trying to achieve? |
Instead of making change in
|
…x/48401-unable-save-waypoint-on-error
@sobitneupane will this code remove error messages even when there is invalid waypoints? Or did you mean to extract this change to |
When we open waypoint editor, the transaction backup will be created. When a backup created it will also clone the errors. If we tap back button without saving the editor, this transaction backup will be restored, including its error message. If we apply this change without modifying clearError, we only clear the error from main transaction onyx data |
Explanation of Change
This PR fixes route validation for offline modifications with waypoint errors.
Fixed Issues
$ #48401
PROPOSAL: #48401 (comment)
Tests
Offline tests
Same as test
QA Steps
Same as test
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Kapture.2024-11-19.at.09.54.25.mp4
Kapture.2024-11-19.at.09.56.24.mp4
Android: mWeb Chrome
Kapture.2024-11-19.at.10.32.22.mp4
Kapture.2024-11-19.at.10.34.22.mp4
iOS: Native
Kapture.2024-11-19.at.09.26.15.mp4
Kapture.2024-11-19.at.09.30.15.mp4
iOS: mWeb Safari
Kapture.2024-11-19.at.09.44.19.mp4
Kapture.2024-11-19.at.09.46.59.mp4
MacOS: Chrome / Safari
Kapture.2024-11-19.at.09.15.10.mp4
Kapture.2024-11-19.at.09.21.47.mp4
MacOS: Desktop
Kapture.2024-11-19.at.10.01.31.mp4
Kapture.2024-11-19.at.10.03.12.mp4