-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Gets the personal details data with useOnyx - #1 #90000
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e76cecc
3a56653
3ec8277
4b0b7ae
82124b2
4196186
91a8b0c
2c131c3
4c44ce2
c2f5d53
ce8d339
d1d315f
a5a60c5
9db2778
a140699
1844b80
08cd3eb
03a113b
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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import {Str} from 'expensify-common'; | ||
| import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; | ||
| import Onyx from 'react-native-onyx'; | ||
| import type {LocaleContextProps} from '@components/LocaleContextProvider'; | ||
| import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {OnyxInputOrEntry, PersonalDetails, PersonalDetailsList, PrivatePersonalDetails} from '@src/types/onyx'; | ||
|
|
@@ -136,6 +136,43 @@ | |
| return result; | ||
| } | ||
|
|
||
| function newGetPersonalDetailsByIDs(params: { | ||
| accountIDs: number[]; | ||
| personalDetails: OnyxEntry<PersonalDetailsList>; | ||
| shouldChangeUserDisplayName: true; | ||
| currentUserAccountID: number | undefined; | ||
| translate: LocalizedTranslate; | ||
| }): PersonalDetails[]; | ||
| function newGetPersonalDetailsByIDs(params: {accountIDs: number[]; personalDetails: OnyxEntry<PersonalDetailsList>; shouldChangeUserDisplayName?: false}): PersonalDetails[]; | ||
| function newGetPersonalDetailsByIDs({ | ||
|
bernhardoj marked this conversation as resolved.
Outdated
bernhardoj marked this conversation as resolved.
Outdated
|
||
| accountIDs, | ||
| personalDetails, | ||
|
Check failure on line 149 in src/libs/PersonalDetailsUtils.ts
|
||
| currentUserAccountID, | ||
| shouldChangeUserDisplayName = false, | ||
| translate, | ||
| }: { | ||
| accountIDs: number[]; | ||
| personalDetails: OnyxEntry<PersonalDetailsList>; | ||
| currentUserAccountID?: number; | ||
| shouldChangeUserDisplayName?: boolean; | ||
| translate?: LocalizedTranslate; | ||
| }): PersonalDetails[] { | ||
| const result: PersonalDetails[] = []; | ||
| for (const accountID of accountIDs) { | ||
| const detail = personalDetails?.[accountID]; | ||
| if (!detail) { | ||
| continue; | ||
| } | ||
|
|
||
| if (shouldChangeUserDisplayName && currentUserAccountID === detail.accountID && translate) { | ||
| result.push({...detail, displayName: translate('common.you')}); | ||
| } else { | ||
| result.push(detail); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
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. is it possible to make this function pure? I personally don't like the common pattern in our codebase that extends simple functions with multiple parameters just to satisfy some rare condition. Here we need to subscribe and pass
just to push a different display name for a single (user) account
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. additionally, how big can be a list of
Contributor
Author
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. Updated to handle showing You on the consumer. So far, the usages are on the reaction list and the domain add member page.
What string to return? Stringifying the detail object? |
||
|
|
||
| function getPersonalDetailByEmail(email: string | undefined): PersonalDetails | undefined { | ||
| if (!email) { | ||
| return undefined; | ||
|
|
@@ -458,6 +495,7 @@ | |
| export { | ||
| getDisplayNameOrDefault, | ||
| getPersonalDetailsByIDs, | ||
| newGetPersonalDetailsByIDs, | ||
| getPersonalDetailByEmail, | ||
| getAccountIDsByLogins, | ||
| getLoginsByAccountIDs, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.