From 76be3a59a9fed5fd0dfe0e640f583b7501c394f6 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 11 Dec 2023 11:34:59 +0700 Subject: [PATCH 1/2] create personal detail optimistic data when inviting member to the room --- src/libs/Permissions.ts | 1 + src/libs/actions/Report.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 43e7ef9fbbc8..338c36766878 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -3,6 +3,7 @@ import CONST from '@src/CONST'; import Beta from '@src/types/onyx/Beta'; function canUseAllBetas(betas: OnyxEntry): boolean { + return true; return !!betas?.includes(CONST.BETAS.ALL); } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 5bc6bfe8c58d..3c6af417aff4 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -16,6 +16,7 @@ import * as ErrorUtils from '@libs/ErrorUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import LocalNotification from '@libs/Notification/LocalNotification'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as Pusher from '@libs/Pusher/pusher'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; @@ -2119,6 +2120,9 @@ function inviteToRoom(reportID, inviteeEmailsToAccountIDs) { const {participantAccountIDs} = report; const participantAccountIDsAfterInvitation = _.uniq([...participantAccountIDs, ...inviteeAccountIDs]); + const logins = _.map(inviteeEmails, (memberLogin) => OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin)); + const newPersonalDetailsOnyxData = PersonalDetailsUtils.getNewPersonalDetailsOnyxData(logins, inviteeAccountIDs); + API.write( 'InviteToRoom', { @@ -2134,7 +2138,9 @@ function inviteToRoom(reportID, inviteeEmailsToAccountIDs) { participantAccountIDs: participantAccountIDsAfterInvitation, }, }, + ...newPersonalDetailsOnyxData.optimisticData, ], + successData: newPersonalDetailsOnyxData.successData, failureData: [ { onyxMethod: Onyx.METHOD.MERGE, @@ -2143,6 +2149,7 @@ function inviteToRoom(reportID, inviteeEmailsToAccountIDs) { participantAccountIDs, }, }, + ...newPersonalDetailsOnyxData.failureData, ], }, ); From f1d598e86d8f3a00dfb9e5873a7514619ba0098c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 11 Dec 2023 11:45:14 +0700 Subject: [PATCH 2/2] remove hard code --- src/libs/Permissions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 338c36766878..43e7ef9fbbc8 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -3,7 +3,6 @@ import CONST from '@src/CONST'; import Beta from '@src/types/onyx/Beta'; function canUseAllBetas(betas: OnyxEntry): boolean { - return true; return !!betas?.includes(CONST.BETAS.ALL); }