Skip to content
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

Personal details list migration: fix Header not displayed while sending money #20679

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
reportName = ReportUtils.getReportName(report);
} else {
reportName = ReportUtils.getDisplayNameForParticipant(accountIDs[0]);
result.keyForList = accountIDs[0];
result.keyForList = String(accountIDs[0]);
mountiny marked this conversation as resolved.
Show resolved Hide resolved
result.alternateText = '';
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/UserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function getSmallSizeAvatar(avatarURL, accountID) {
* @returns {Number}
*/
function generateAccountID() {
return (Math.floor(Math.random() * 2 ** 21) * 2 ** 32 + Math.floor(Math.random() * 2 ** 32));
return Math.floor(Math.random() * 2 ** 21) * 2 ** 32 + Math.floor(Math.random() * 2 ** 32);
}

export {
Expand Down
20 changes: 20 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -937,6 +938,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,
Expand All @@ -962,6 +965,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: {
[recipient.accountID]: {
accountID: recipient.accountID,
avatar: UserUtils.getDefaultAvatarURL(recipient.accountID),
BeeMargarida marked this conversation as resolved.
Show resolved Hide resolved
displayName: recipient.displayName || recipient.login,
login: recipient.login,
},
},
};

// Add an optimistic created action to the optimistic reportActions data
optimisticReportActionsData.value[optimisticCreatedAction.reportActionID] = optimisticCreatedAction;

Expand All @@ -970,6 +987,9 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
}

const optimisticData = [optimisticChatReportData, optimisticIOUReportData, optimisticReportActionsData, optimisticTransactionData];
if (!_.isEmpty(optimisticPersonalDetailListData)) {
optimisticData.push(optimisticPersonalDetailListData);
}

return {
params: {
Expand Down