-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Personal details list migration: fix Header not displayed while sending money
#20679
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
Changes from all commits
1faa94b
c840d82
e549f6d
a166ad7
019af1f
b7844c3
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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import * as OptionsListUtils from '../OptionsListUtils'; | |
| import DateUtils from '../DateUtils'; | ||
| import TransactionUtils from '../TransactionUtils'; | ||
| import * as ErrorUtils from '../ErrorUtils'; | ||
| import * as UserUtils from '../UserUtils'; | ||
|
|
||
| const chatReports = {}; | ||
| const iouReports = {}; | ||
|
|
@@ -51,6 +52,7 @@ function buildOnyxDataForMoneyRequest( | |
| chatCreatedAction, | ||
| iouCreatedAction, | ||
| iouAction, | ||
| optimisticPersonalDetailListAction, | ||
| reportPreviewAction, | ||
| isNewChatReport, | ||
| isNewIOUReport, | ||
|
|
@@ -104,6 +106,14 @@ function buildOnyxDataForMoneyRequest( | |
| }, | ||
| ]; | ||
|
|
||
| if (isNewChatReport && !_.isEmpty(optimisticPersonalDetailListAction)) { | ||
| optimisticData.push({ | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| value: optimisticPersonalDetailListAction, | ||
| }); | ||
| } | ||
|
Comment on lines
+109
to
+115
Member
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. This caused a regression. Merging the personal data should only be done only if it's not in Onyx already. Otherwise we would overwrite the existing user data e.g. displayName. |
||
|
|
||
| const successData = [ | ||
| ...(isNewChatReport | ||
| ? [ | ||
|
|
@@ -327,6 +337,16 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part | |
| iouReport.reportID, | ||
| ); | ||
|
|
||
| // Add optimistic personal details for participant | ||
|
BeeMargarida marked this conversation as resolved.
|
||
| const optimisticPersonalDetailListAction = { | ||
| [payerAccountID]: { | ||
| accountID: payerAccountID, | ||
| avatar: UserUtils.getDefaultAvatarURL(payerAccountID), | ||
| displayName: participant.displayName || payerEmail, | ||
| login: participant.login, | ||
| }, | ||
| }; | ||
|
|
||
| let isNewReportPreviewAction = false; | ||
| let reportPreviewAction = isNewIOUReport ? null : ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID); | ||
| if (!reportPreviewAction) { | ||
|
|
@@ -342,6 +362,7 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part | |
| optimisticCreatedActionForChat, | ||
| optimisticCreatedActionForIOU, | ||
| optimisticIOUAction, | ||
| optimisticPersonalDetailListAction, | ||
| reportPreviewAction, | ||
| isNewChatReport, | ||
| isNewIOUReport, | ||
|
|
@@ -564,6 +585,16 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco | |
| oneOnOneIOUReport.reportID, | ||
| ); | ||
|
|
||
| // Add optimistic personal details for new participants | ||
|
BeeMargarida marked this conversation as resolved.
|
||
| const oneOnOnePersonalDetailListAction = { | ||
| [accountID]: { | ||
| accountID, | ||
|
mountiny marked this conversation as resolved.
|
||
| avatar: UserUtils.getDefaultAvatarURL(accountID), | ||
| displayName: participant.displayName || email, | ||
| login: participant.login, | ||
| }, | ||
| }; | ||
|
|
||
| let isNewOneOnOneReportPreviewAction = false; | ||
| let oneOnOneReportPreviewAction = ReportActionsUtils.getReportPreviewAction(oneOnOneChatReport.reportID, oneOnOneIOUReport.reportID); | ||
| if (!oneOnOneReportPreviewAction) { | ||
|
|
@@ -579,6 +610,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco | |
| oneOnOneCreatedActionForChat, | ||
| oneOnOneCreatedActionForIOU, | ||
| oneOnOneIOUAction, | ||
| oneOnOnePersonalDetailListAction, | ||
| oneOnOneReportPreviewAction, | ||
| isNewOneOnOneChatReport, | ||
| isNewOneOnOneIOUReport, | ||
|
|
@@ -937,6 +969,8 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType | |
| }, | ||
| ]; | ||
|
|
||
| let optimisticPersonalDetailListData = {}; | ||
|
|
||
| // Now, let's add the data we need just when we are creating a new chat report | ||
| if (isNewChat) { | ||
| // Change the method to set for new reports because it doesn't exist yet, is faster, | ||
|
|
@@ -962,6 +996,20 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType | |
| }, | ||
| }); | ||
|
|
||
| // Add optimistic personal details for recipient | ||
| optimisticPersonalDetailListData = { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| value: { | ||
| [recipientAccountID]: { | ||
| accountID: recipientAccountID, | ||
| avatar: UserUtils.getDefaultAvatarURL(recipient.accountID), | ||
| displayName: recipient.displayName || recipient.login, | ||
| login: recipient.login, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| // Add an optimistic created action to the optimistic reportActions data | ||
| optimisticReportActionsData.value[optimisticCreatedAction.reportActionID] = optimisticCreatedAction; | ||
|
|
||
|
|
@@ -970,6 +1018,9 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType | |
| } | ||
|
|
||
| const optimisticData = [optimisticChatReportData, optimisticIOUReportData, optimisticReportActionsData, optimisticTransactionData]; | ||
| if (!_.isEmpty(optimisticPersonalDetailListData)) { | ||
| optimisticData.push(optimisticPersonalDetailListData); | ||
| } | ||
|
|
||
| return { | ||
| params: { | ||
|
|
@@ -1007,6 +1058,12 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho | |
| iouReport.reportID, | ||
| true, | ||
| ); | ||
| const optimisticPersonalDetailsListAction = { | ||
| accountID: Number(recipient.accountID), | ||
| avatar: UserUtils.getDefaultAvatarURL(Number(recipient.accountID)), | ||
| displayName: recipient.displayName || recipient.login, | ||
| login: recipient.login, | ||
| }; | ||
|
Comment on lines
+1061
to
+1066
Contributor
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. There was a copy/paste mistake here. This data itself (without accountID key) is added in |
||
|
|
||
| const optimisticData = [ | ||
| { | ||
|
|
@@ -1053,6 +1110,11 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho | |
| key: ONYXKEYS.NVP_LAST_PAYMENT_METHOD, | ||
| value: {[iouReport.policyID]: paymentMethodType}, | ||
| }, | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| value: optimisticPersonalDetailsListAction, | ||
| }, | ||
| ]; | ||
|
|
||
| const successData = [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.