From 9cff1f47b2d86b64fe99ae77218b8ad3ca401226 Mon Sep 17 00:00:00 2001 From: bartektomczyk Date: Wed, 10 Apr 2024 08:47:26 +0200 Subject: [PATCH] feat: added optimistic data --- src/libs/actions/Report.ts | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 8b280e11973b..3edd4515a1d2 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -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; @@ -1939,16 +1944,6 @@ function deleteReport(reportID: string) { Onyx.multiSet(onyxData); - // Clear the optimistic personal detail - const participantPersonalDetails: OnyxCollection = {}; - 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); @@ -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, @@ -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}); }