Skip to content

Commit

Permalink
More cleanup & adding consts
Browse files Browse the repository at this point in the history
  • Loading branch information
Beamanator committed Jun 15, 2023
1 parent b30a6dd commit 320bcca
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ const CONST = {
MAX_ROOM_NAME_LENGTH: 79,
LAST_MESSAGE_TEXT_MAX_LENGTH: 200,
OWNER_EMAIL_FAKE: '__FAKE__',
OWNER_ACCOUNT_ID_FAKE: 0,
DEFAULT_REPORT_NAME: 'Chat Report',
},
COMPOSER: {
Expand Down Expand Up @@ -1078,6 +1079,7 @@ const CONST = {
ROOM_PREFIX: '#',
CUSTOM_UNIT_RATE_BASE_OFFSET: 100,
OWNER_EMAIL_FAKE: '_FAKE_',
OWNER_ACCOUNT_ID_FAKE: 0,
},

CUSTOM_UNITS: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function MoneyRequestAction(props) {
'',
CONST.POLICY.OWNER_EMAIL_FAKE,
CONST.POLICY.OWNER_EMAIL_FAKE,
0,
CONST.POLICY.OWNER_ACCOUNT_ID_FAKE,
false,
'',
undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/components/participantPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default PropTypes.shape({
login: PropTypes.string,

// Account ID of participant
accountID: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
accountID: PropTypes.number,

// Display Name of participant
displayName: PropTypes.string,
Expand Down
35 changes: 15 additions & 20 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,22 @@ function getPersonalDetailsForAccountIDs(accountIDs, personalDetails) {
if (!personalDetails) {
return personalDetailsForAccountIDs;
}
_.chain(accountIDs)
// NOTE: this comment is possibly legacy, we need to verify if it's still true
// Somehow it's possible for the accountIDs coming from report.participantAccountIDs to contain undefined values so we use compact to remove them.
.compact()
.each((accountID) => {
const cleanAccountID = Number(accountID);
let personalDetail = personalDetails[accountID];
if (!personalDetail) {
// NOTE: this can possibly be changed to 'hidden'
personalDetail = {
accountID: cleanAccountID,
avatar: UserUtils.getDefaultAvatar(cleanAccountID),
};
}
_.each(accountIDs, (accountID) => {
const cleanAccountID = Number(accountID);
let personalDetail = personalDetails[accountID];
if (!personalDetail) {
personalDetail = {
accountID: cleanAccountID,
avatar: UserUtils.getDefaultAvatar(cleanAccountID),
};
}

if (cleanAccountID === CONST.ACCOUNT_ID.CONCIERGE) {
personalDetail.avatar = CONST.CONCIERGE_ICON_URL;
}
if (cleanAccountID === CONST.ACCOUNT_ID.CONCIERGE) {
personalDetail.avatar = CONST.CONCIERGE_ICON_URL;
}

personalDetailsForAccountIDs[cleanAccountID] = personalDetail;
});
personalDetailsForAccountIDs[cleanAccountID] = personalDetail;
});
return personalDetailsForAccountIDs;
}

Expand Down Expand Up @@ -373,7 +368,7 @@ function getAllReportErrors(report, reportActions) {
/**
* Creates a report list option
*
* @param {Array<String>} accountIDs
* @param {Array<Number>} accountIDs
* @param {Object} personalDetails
* @param {Object} report
* @param {Object} reportActions
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ function buildOptimisticChatReport(
chatType = '',
policyID = CONST.POLICY.OWNER_EMAIL_FAKE,
ownerEmail = CONST.REPORT.OWNER_EMAIL_FAKE,
ownerAccountID = 0,
ownerAccountID = CONST.REPORT.OWNER_ACCOUNT_ID_FAKE,
isOwnPolicyExpenseChat = false,
oldPolicyName = '',
visibility = undefined,
Expand All @@ -1534,7 +1534,7 @@ function buildOptimisticChatReport(
notificationPreference,
oldPolicyName,
ownerEmail: ownerEmail || CONST.REPORT.OWNER_EMAIL_FAKE,
ownerAccountID: ownerAccountID || 0,
ownerAccountID: ownerAccountID || CONST.REPORT.OWNER_ACCOUNT_ID_FAKE,
parentReportActionID,
parentReportID,
participantAccountIDs: participantList,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function navigateToAndOpenChildReport(childReportID = '0', parentReportAction =
lodashGet(parentReport, 'chatType', ''),
lodashGet(parentReport, 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE),
CONST.POLICY.OWNER_EMAIL_FAKE,
0,
CONST.POLICY.OWNER_ACCOUNT_ID_FAKE,
false,
'',
undefined,
Expand Down Expand Up @@ -1159,7 +1159,7 @@ function addPolicyReport(policy, reportName, visibility) {
CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
policy.id,
CONST.REPORT.OWNER_EMAIL_FAKE,
0,
CONST.REPORT.OWNER_ACCOUNT_ID_FAKE,
false,
'',
visibility,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/personalDetailsPropType.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default PropTypes.shape({
avatarUploading: PropTypes.bool,

// accountID of the current user from their personal details
accountID: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
accountID: PropTypes.number,

// login of the current user from their personal details
login: PropTypes.string,
Expand Down

0 comments on commit 320bcca

Please sign in to comment.