Skip to content

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

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/libs/actions/PersistedRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ function save(requestsToPersist) {
* @param {Object} requestToRemove
*/
function remove(requestToRemove) {
persistedRequests = _.reject(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove));
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests);
const persistedRequestsCopy = _.clone(persistedRequests);
const index = _.findIndex(persistedRequestsCopy, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove));
if (index !== -1) {
persistedRequestsCopy.splice(index, 1);
persistedRequests = persistedRequestsCopy;
Copy link
Contributor

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?

Copy link
Contributor Author

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));

Copy link
Contributor

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?

}

Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequestsCopy);
}

/**
Expand Down