Skip to content

Commit 73a784d

Browse files
authored
Merge pull request Expensify#74560 from DylanDylann/fix-app-perf
[No QA]: Fix App performance
2 parents 0be1450 + 54e7494 commit 73a784d

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

src/libs/PersonalDetailsUtils.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,31 @@ Onyx.connect({
3636
},
3737
});
3838

39+
let hiddenTranslation = '';
40+
let youTranslation = '';
41+
42+
Onyx.connect({
43+
key: ONYXKEYS.ARE_TRANSLATIONS_LOADING,
44+
initWithStoredValues: false,
45+
callback: (value) => {
46+
if (value ?? true) {
47+
return;
48+
}
49+
// eslint-disable-next-line @typescript-eslint/no-deprecated
50+
hiddenTranslation = translateLocal('common.hidden');
51+
// eslint-disable-next-line @typescript-eslint/no-deprecated
52+
youTranslation = translateLocal('common.you').toLowerCase();
53+
},
54+
});
55+
3956
const regexMergedAccount = new RegExp(CONST.REGEX.MERGED_ACCOUNT_PREFIX);
4057

4158
function getDisplayNameOrDefault(
4259
passedPersonalDetails?: Partial<PersonalDetails> | null,
4360
defaultValue = '',
4461
shouldFallbackToHidden = true,
4562
shouldAddCurrentUserPostfix = false,
46-
// eslint-disable-next-line @typescript-eslint/no-deprecated
47-
youAfterTranslation = translateLocal('common.you').toLowerCase(),
63+
youAfterTranslation = youTranslation,
4864
): string {
4965
let displayName = passedPersonalDetails?.displayName ?? '';
5066

@@ -84,8 +100,7 @@ function getDisplayNameOrDefault(
84100
if (login) {
85101
return login;
86102
}
87-
// eslint-disable-next-line @typescript-eslint/no-deprecated
88-
return shouldFallbackToHidden ? translateLocal('common.hidden') : '';
103+
return shouldFallbackToHidden ? hiddenTranslation : '';
89104
}
90105

91106
/**

src/libs/ReportUtils.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,23 @@ Onyx.connect({
11771177
},
11781178
});
11791179

1180+
let hiddenTranslation = '';
1181+
let unavailableTranslation = '';
1182+
1183+
Onyx.connect({
1184+
key: ONYXKEYS.ARE_TRANSLATIONS_LOADING,
1185+
initWithStoredValues: false,
1186+
callback: (value) => {
1187+
if (value ?? true) {
1188+
return;
1189+
}
1190+
// eslint-disable-next-line @typescript-eslint/no-deprecated
1191+
hiddenTranslation = translateLocal('common.hidden');
1192+
// eslint-disable-next-line @typescript-eslint/no-deprecated
1193+
unavailableTranslation = translateLocal('workspace.common.unavailable');
1194+
},
1195+
});
1196+
11801197
function getCurrentUserAvatar(): AvatarSource | undefined {
11811198
return currentUserPersonalDetails?.avatar;
11821199
}
@@ -1320,8 +1337,7 @@ function getPolicyType(report: OnyxInputOrEntry<Report>, policies: OnyxCollectio
13201337
* Get the policy name from a given report
13211338
*/
13221339
function getPolicyName({report, returnEmptyIfNotFound = false, policy, policies, reports}: GetPolicyNameParams): string {
1323-
// eslint-disable-next-line @typescript-eslint/no-deprecated
1324-
const noPolicyFound: string = returnEmptyIfNotFound ? '' : translateLocal('workspace.common.unavailable');
1340+
const noPolicyFound = returnEmptyIfNotFound ? '' : unavailableTranslation;
13251341
const parentReport = report ? getRootParentReport({report, reports}) : undefined;
13261342

13271343
if (isEmptyObject(report) || (isEmptyObject(policies) && isEmptyObject(allPolicies) && !report?.policyName && !parentReport?.policyName)) {
@@ -3107,8 +3123,7 @@ function getDisplayNameForParticipant({
31073123
}
31083124

31093125
// If the user's personal details (first name) should be hidden, make sure we return "hidden" instead of the short name
3110-
// eslint-disable-next-line @typescript-eslint/no-deprecated
3111-
if (shouldFallbackToHidden && longName === translateLocal('common.hidden')) {
3126+
if (shouldFallbackToHidden && longName === hiddenTranslation) {
31123127
return longName;
31133128
}
31143129

0 commit comments

Comments
 (0)