-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix remove only first request #22727
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
Changes from 5 commits
a36139b
09774bb
a52c6d5
46595c3
94683d9
9489b25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,15 @@ function save(requestsToPersist) { | |
* @param {Object} requestToRemove | ||
*/ | ||
function remove(requestToRemove) { | ||
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 | ||
*/ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. @namhihi237 Mutating the original 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. @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 commentThe reason will be displayed to describe this comment to others. Learn more. updated @allroundexperts |
||
} | ||
|
||
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests); | ||
} | ||
|
||
|
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.