-
Notifications
You must be signed in to change notification settings - Fork 4k
Onyx.connect() removal for ONYXKEYS.SESSION in ReportNameUtils #78605
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
19d7563
Onyx.connect() removal for ONYXKEYS.SESSION in ReportNameUtils
ShridharGoel 2e57fc5
Type and prettier fixes
ShridharGoel 0524a9c
Prettier fix
ShridharGoel fe28b0a
Make currentUserAccountID a required param
ShridharGoel abea3a9
Merge branch 'main' into onyxConnect1
ShridharGoel 3c93f08
Update to have account ID as required param at more places
ShridharGoel ff2d024
Make currentUserAccountID optional in computeReportName
ShridharGoel 8b029ef
Prettier fixes
ShridharGoel e7fad40
Merge branch 'main' into onyxConnect1
ShridharGoel 917f5af
Use useCurrentUserPersonalDetails
ShridharGoel aa384a0
Update
ShridharGoel aa84d4a
Lint fix
ShridharGoel 880f4f4
Update to remove extra CONST.DEFAULT_NUMBER_ID fallbacks
ShridharGoel d681db1
Merge main
ShridharGoel 7cc7337
Get rid of extra changes
ShridharGoel ff91997
Update
ShridharGoel 9e2440c
Decrease usage of default account ID in OptionsListUtils
ShridharGoel 916d559
Decrease usage of default account ID
ShridharGoel b27158b
Lint fixes
ShridharGoel 83ca4dc
Update to not use currentUserId via connectWithoutView
ShridharGoel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,17 +119,9 @@ | |
| isUserCreatedPolicyRoom, | ||
| } from './ReportUtils'; | ||
|
|
||
| let currentUserAccountID: number | undefined; | ||
| let allPersonalDetails: OnyxEntry<PersonalDetailsList>; | ||
|
|
||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| currentUserAccountID = value?.accountID; | ||
| }, | ||
| }); | ||
|
|
||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| allPersonalDetails = value; | ||
|
|
@@ -146,7 +138,15 @@ | |
| * This function is useful in contexts such as 1:1 direct messages (DMs) or other group chats. | ||
| * It limits to a maximum of 5 participants for the title and uses short names unless there is only one participant. | ||
| */ | ||
| const buildReportNameFromParticipantNames = ({report, personalDetailsList: personalDetailsData}: {report: OnyxEntry<Report>; personalDetailsList?: Partial<PersonalDetailsList>}) => | ||
| const buildReportNameFromParticipantNames = ({ | ||
| report, | ||
| personalDetailsList: personalDetailsData, | ||
| currentUserAccountID, | ||
| }: { | ||
| report: OnyxEntry<Report>; | ||
| personalDetailsList?: Partial<PersonalDetailsList>; | ||
| currentUserAccountID?: number; | ||
| }) => | ||
| Object.keys(report?.participants ?? {}) | ||
| .map(Number) | ||
| .filter((id) => id !== currentUserAccountID) | ||
|
|
@@ -255,11 +255,13 @@ | |
| receiverPolicy, | ||
| personalDetails, | ||
| policies, | ||
| currentUserAccountID, | ||
|
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. @ShridharGoel Why currentUserAccountID is optional here?
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. Changed it to a required param |
||
| }: { | ||
| report: OnyxEntry<Report>; | ||
| receiverPolicy: OnyxEntry<Policy>; | ||
| personalDetails?: Partial<PersonalDetailsList>; | ||
| policies?: Policy[]; | ||
| currentUserAccountID?: number; | ||
| }): string { | ||
| const invoiceReceiver = report?.invoiceReceiver; | ||
| const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL; | ||
|
|
@@ -669,6 +671,7 @@ | |
| allReportNameValuePairs?: OnyxCollection<ReportNameValuePairs>, | ||
| personalDetailsList?: PersonalDetailsList, | ||
| reportActions?: OnyxCollection<ReportActions>, | ||
| currentUserAccountID?: number, | ||
| ): string { | ||
| if (!report || !report.reportID) { | ||
| return ''; | ||
|
|
@@ -740,7 +743,7 @@ | |
| receiverPolicyID = (receiver as {policyID: string}).policyID; | ||
| } | ||
| const invoiceReceiverPolicy = receiverPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${receiverPolicyID}`] : undefined; | ||
| formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList}); | ||
| formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList, currentUserAccountID}); | ||
| } | ||
|
|
||
| if (isSelfDM(report)) { | ||
|
|
@@ -761,7 +764,7 @@ | |
| } | ||
|
|
||
| // Not a room or PolicyExpenseChat, generate title from first 5 other participants | ||
| formattedName = buildReportNameFromParticipantNames({report, personalDetailsList}); | ||
| formattedName = buildReportNameFromParticipantNames({report, personalDetailsList, currentUserAccountID}); | ||
|
|
||
| const finalName = formattedName ?? report?.reportName ?? ''; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShridharGoel AFAIK, our target is to remove the usage of
Onyx.connect, However, this change goes against the target because it uses a otherOnyx.connectcc @tgolen @shubham1206agra
Never mind, I’ll remove them here