-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: optimistically add personal details #22904
Changes from 5 commits
9cbe95d
571da94
f0d3a67
e6881a1
67258bf
1ee57d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ROUTES from '../../ROUTES'; | |
import * as OptionsListUtils from '../OptionsListUtils'; | ||
import * as ErrorUtils from '../ErrorUtils'; | ||
import * as ReportUtils from '../ReportUtils'; | ||
import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; | ||
import Log from '../Log'; | ||
import Permissions from '../Permissions'; | ||
|
||
|
@@ -354,7 +355,9 @@ function createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas) { | |
*/ | ||
function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID, betas) { | ||
const membersListKey = `${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${policyID}`; | ||
const logins = _.map(_.keys(invitedEmailsToAccountIDs), (memberLogin) => OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin)); | ||
const accountIDs = _.values(invitedEmailsToAccountIDs); | ||
const newPersonalDetailsOnyxData = PersonalDetailsUtils.getNewPersonalDetailsOnyxData(logins, accountIDs); | ||
|
||
// create onyx data for policy expense chats for each new member | ||
const membersChats = createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems we're doing same work in different issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc: @rezkiy37 @madmax330 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@0xmiroslav can you update your PR to do this? Then the two would complement each other right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #22410 is more optimized code as reusing optimistic members from workspace chat. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, go ahead and resolve the conflict in #22410 and we will review. |
||
|
@@ -367,6 +370,7 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID, | |
// Convert to object with each key containing {pendingAction: ‘add’} | ||
value: _.object(accountIDs, Array(accountIDs.length).fill({pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD})), | ||
}, | ||
...newPersonalDetailsOnyxData.optimisticData, | ||
...membersChats.onyxOptimisticData, | ||
]; | ||
|
||
|
@@ -379,6 +383,7 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID, | |
// need to remove the members since that will be handled by onClose of OfflineWithFeedback. | ||
value: _.object(accountIDs, Array(accountIDs.length).fill({pendingAction: null, errors: null})), | ||
}, | ||
...newPersonalDetailsOnyxData.successData, | ||
...membersChats.onyxSuccessData, | ||
]; | ||
|
||
|
@@ -396,10 +401,10 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID, | |
}), | ||
), | ||
}, | ||
...newPersonalDetailsOnyxData.failureData, | ||
...membersChats.onyxFailureData, | ||
]; | ||
|
||
const logins = _.map(_.keys(invitedEmailsToAccountIDs), (memberLogin) => OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin)); | ||
const params = { | ||
employees: JSON.stringify(_.map(logins, (login) => ({email: login}))), | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is incomplete. Can you please indicate that this is done to prevent duplicated entries since the server will return other personal details with the correct account ids.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I've expanded it. Let me know what you think.