Skip to content

Commit

Permalink
Merge pull request #22727 from namhihi237/fix-19640-notification-inco…
Browse files Browse the repository at this point in the history
…nsistently

fix remove only first request
  • Loading branch information
puneetlath authored Jul 24, 2023
2 parents 64e719e + 9489b25 commit ff54c9e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libs/actions/PersistedRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ function save(requestsToPersist) {
* @param {Object} requestToRemove
*/
function remove(requestToRemove) {
persistedRequests = _.reject(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove));
/**
* 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.
*/
const index = _.findIndex(persistedRequests, (persistedRequest) => _.isEqual(persistedRequest, requestToRemove));
if (index !== -1) {
persistedRequests.splice(index, 1);
}

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

Expand Down

0 comments on commit ff54c9e

Please sign in to comment.