Skip to content

Commit

Permalink
keep save function and reassign persistedRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
namhihi237 committed Oct 4, 2023
1 parent 760b049 commit 658bffa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/libs/actions/PersistedRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ function clear() {
}

function save(requestsToPersist: Request[]) {
let requests = [];
if (persistedRequests.length) {
requests = persistedRequests.concat(requestsToPersist);
persistedRequests = persistedRequests.concat(requestsToPersist);
} else {
requests = requestsToPersist;
persistedRequests = requestsToPersist;
}
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, requests);
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests);
}

function remove(requestToRemove: Request) {
Expand All @@ -38,12 +37,14 @@ function remove(requestToRemove: Request) {
}
const requests = [...persistedRequests];
requests.splice(index, 1);
persistedRequests = requests;
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, requests);
}

function update(oldRequestIndex: number, newRequest: Request) {
const requests = [...persistedRequests];
requests.splice(oldRequestIndex, 1, newRequest);
persistedRequests = requests;
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, requests);
}

Expand Down

0 comments on commit 658bffa

Please sign in to comment.