From 901ae74c80089f8ad95f59462f87bcc5b514fb79 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 27 Nov 2024 15:00:17 +0700 Subject: [PATCH 1/2] fix: remove pinned SelfDM for new users --- src/libs/actions/Report.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index efd8ca63350d..a888b81dcef6 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3882,6 +3882,27 @@ function prepareOnboardingOptimisticData( guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); } + const selfDMReportID = ReportUtils.findSelfDMReportID(); + const selfDMReport = ReportConnection.getReport(selfDMReportID ?? '-1'); + + if (engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`, + value: { + isPinned: false, + }, + }); + + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`, + value: { + isPinned: selfDMReport?.isPinned, + }, + }); + } + guidedSetupData.push(...tasksForParameters); return {optimisticData, successData, failureData, guidedSetupData, actorAccountID}; From 7a421c042739fc7a11ce07ac05554f56b0025f91 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 28 Nov 2024 14:05:12 +0700 Subject: [PATCH 2/2] refactor code --- src/libs/actions/Report.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index a888b81dcef6..9d1bb7ce5eda 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3882,10 +3882,9 @@ function prepareOnboardingOptimisticData( guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); } - const selfDMReportID = ReportUtils.findSelfDMReportID(); - const selfDMReport = ReportConnection.getReport(selfDMReportID ?? '-1'); - if (engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { + const selfDMReportID = ReportUtils.findSelfDMReportID(); + const selfDMReport = ReportConnection.getReport(selfDMReportID ?? '-1'); optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`,