Skip to content

Commit

Permalink
feat: added optimistic data
Browse files Browse the repository at this point in the history
  • Loading branch information
barttom committed Apr 10, 2024
1 parent 9ad3329 commit 9cff1f4
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ function openReport(
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: settledPersonalDetails,
});
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: settledPersonalDetails,
});

// Add the createdReportActionID parameter to the API call
parameters.createdReportActionID = optimisticCreatedAction.reportActionID;
Expand Down Expand Up @@ -1939,16 +1944,6 @@ function deleteReport(reportID: string) {

Onyx.multiSet(onyxData);

// Clear the optimistic personal detail
const participantPersonalDetails: OnyxCollection<PersonalDetails> = {};
report?.participantAccountIDs?.forEach((accountID) => {
if (!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail) {
return;
}
participantPersonalDetails[accountID] = null;
});
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, participantPersonalDetails);

// Delete linked IOU report
if (report?.iouReportID) {
deleteReport(report.iouReportID);
Expand Down Expand Up @@ -2900,7 +2895,7 @@ function completeOnboarding(properties: {
return [
...acc,
{
onyxMethod: Onyx.METHOD.MERGE,
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${currTask.reportID}`,
value: {
...currTask,
Expand Down Expand Up @@ -2967,9 +2962,6 @@ function completeOnboarding(properties: {
data: JSON.stringify([{type: 'message', ...textMessage}, {type: 'video', ...data.video, ...videoMessage}, ...tasksForParameters]),
};

// console.log('-------------------------------------');
// console.log(JSON.stringify({...parameters, data: JSON.parse(parameters.data)}, ' ', 2));

API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData});
}

Expand Down

0 comments on commit 9cff1f4

Please sign in to comment.