Skip to content
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

use getIconsForParticipants for icons in getAssignee in Task #23773

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,19 @@ function clearOutTaskInfoAndNavigate(reportID) {
* Get the assignee data
*
* @param {Object} details
* @param {Object} personalDetails
* @returns {Object}
*/
function getAssignee(details) {
function getAssignee(details, personalDetails) {
if (!details) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can get params assigneeAccountID instead of details & personalDetails.

Compute details here like this

details = personalDetails[assigneeAccountID];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return {
icons: [],
displayName: '',
subtitle: '',
};
}
const source = UserUtils.getAvatar(lodashGet(details, 'avatar', ''), lodashGet(details, 'accountID', -1));
return {
icons: [{source, type: 'avatar', name: details.login}],
icons: ReportUtils.getIconsForParticipants([details.accountID], personalDetails),
displayName: details.displayName,
subtitle: details.login,
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/NewTaskPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function NewTaskPage(props) {
if (!assigneeDetails) {
return setErrorMessage(props.translate('task.assigneeError'));
}
const displayDetails = Task.getAssignee(assigneeDetails);
const displayDetails = Task.getAssignee(assigneeDetails, props.personalDetails);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing something unnecessary computing for assigneeDetails let's remove that here.
And just pass assigneeAccountID & personalDetails for the getAssignee method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Changed to passing assigneeAccountID and removed assigneeDetails lines. These lines are in props.task.assignee is true so assigneeDetails will never be falsy here, and the error returning line can be safely removed.

setAssignee(displayDetails);
}

Expand Down
Loading