File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,15 @@ function save(requestsToPersist) {
25
25
* @param {Object } requestToRemove
26
26
*/
27
27
function remove ( requestToRemove ) {
28
- persistedRequests = _ . reject ( persistedRequests , ( persistedRequest ) => _ . isEqual ( persistedRequest , requestToRemove ) ) ;
28
+ /**
29
+ * We only remove the first matching request because the order of requests matters.
30
+ * If we were to remove all matching requests, we can end up with a final state that is different than what the user intended.
31
+ */
32
+ const index = _ . findIndex ( persistedRequests , ( persistedRequest ) => _ . isEqual ( persistedRequest , requestToRemove ) ) ;
33
+ if ( index !== - 1 ) {
34
+ persistedRequests . splice ( index , 1 ) ;
35
+ }
36
+
29
37
Onyx . set ( ONYXKEYS . PERSISTED_REQUESTS , persistedRequests ) ;
30
38
}
31
39
You can’t perform that action at this time.
0 commit comments