Skip to content

Commit

Permalink
Merge pull request #46282 from callstack-internal/fix/optimize-getDis…
Browse files Browse the repository at this point in the history
…playNameForParticipant

fix: further optimization of getDisplayNameForParticipant
  • Loading branch information
techievivek committed Jul 29, 2024
2 parents 6fcca3c + 800423b commit d8d7f78
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,13 @@ function getPersonalDetailsForAccountID(accountID: number): Partial<PersonalDeta
return allPersonalDetails?.[accountID] ?? defaultDetails;
}

/**
* Returns the personal details or a default object if the personal details are not available.
*/
function getPersonalDetailsOrDefault(personalDetails: Partial<PersonalDetails> | undefined | null): Partial<PersonalDetails> {
return personalDetails ?? {isOptimisticPersonalDetail: true};
}

const hiddenTranslation = Localize.translateLocal('common.hidden');

const phoneNumberCache: Record<string, string> = {};
Expand All @@ -1909,7 +1916,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f
return '';
}

const personalDetails = getPersonalDetailsForAccountID(accountID);
const personalDetails = getPersonalDetailsOrDefault(allPersonalDetails?.[accountID]);
if (!personalDetails) {
return '';
}
Expand Down

0 comments on commit d8d7f78

Please sign in to comment.