-
Notifications
You must be signed in to change notification settings - Fork 3k
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 remove only first request #22727
fix remove only first request #22727
Conversation
@allroundexperts 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] |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-07-13.at.1.18.33.AM.movMobile Web - ChromeScreen.Recording.2023-07-13.at.1.28.22.AM.movMobile Web - SafariScreen.Recording.2023-07-13.at.1.47.10.AM.movDesktopScreen.Recording.2023-07-13.at.1.21.40.AM.moviOSScreen.Recording.2023-07-13.at.1.34.10.AM.movAndroidScreen.Recording.2023-07-13.at.1.32.42.AM.mov |
persistedRequests = _.reject(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove)); | ||
const index = _.findIndex(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove)); | ||
if (index !== -1) { | ||
persistedRequests.splice(index, 1); |
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.
@namhihi237 Mutating the original persistedRequests
array really makes me anxious. Can we please mutate a copy of the original?
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.
@allroundexperts yes sure to avoid mutating the original persistedRequests array, we can make a copy of the array before modifying it.
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.
updated @allroundexperts
const index = _.findIndex(persistedRequestsCopy, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove)); | ||
if (index !== -1) { | ||
persistedRequestsCopy.splice(index, 1); | ||
persistedRequests = persistedRequestsCopy; |
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.
Why do we need this line?
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.
we need to update persistedRequests array define global as you can see the current code:
persistedRequests = _.reject(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove));
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.
Hm... Thinking about it again, I think your previous changes were fine. Can you revert?
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.
Looking good!
Hi @puneetlath, when you have free time can you take a look at this. |
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.
Sorry for the delay! This looks good to me!
Just one request -- can we add a comment or function description explaining that we are removing the first matching request only, even if there are multiple matching requests.
Added @puneetlath Thanks for back review |
Bump on this @puneetlath |
persistedRequests = _.reject(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove)); | ||
/** | ||
* Removes the first matching request, even if there are multiple matching requests. | ||
* Because if multiple identical requests are queued. We want to keep the same requests then see more here: https://github.com/Expensify/App/issues/19640 |
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.
* Because if multiple identical requests are queued. We want to keep the same requests then see more here: https://github.com/Expensify/App/issues/19640 | |
* We only remove the first matching request because the order of requests matters. | |
* If we were to remove all matching requests, we can end up with a final state that is different than what the user intended. |
@puneetlath updated with your suggestion, thanks |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.45-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.45-7 🚀
|
Details
Fixed Issues
$ #19640
PROPOSAL: #19640 (comment)
Tests
Offline tests
The same test
QA Steps
The same test
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
web.mov
Mobile Web - Chrome
m-web.mov
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
native-ios.mov
Android
native.-android.mov