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

fix workspace avatar it not updated #19750

Merged
merged 10 commits into from
Jun 5, 2023
4 changes: 4 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ class ReportScreen extends React.Component {
const shouldAnimate = !shouldFreeze;
const parentReportAction = ReportActionsUtils.getParentReportAction(this.props.report);
const isSingleTransactionView = ReportActionsUtils.isTransactionThread(parentReportAction);

const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];

return (
<ScreenWrapper style={screenWrapperStyle}>
<Freeze
Expand Down Expand Up @@ -340,6 +343,7 @@ class ReportScreen extends React.Component {
isComposerFullSize={this.props.isComposerFullSize}
isDrawerOpen={this.props.isDrawerOpen}
parentViewHeight={this.state.skeletonViewContainerHeight}
policy={policy}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pass the policies directly and have the filter in ReportActionsView similar to how MoneyRequestHeader is doing?

policies={this.props.policies}

The reason I saying is, for normal chats and group chats the policy would be undefined and we would be passing a undefined value, which won't be a good code practice. With the proposed way it will be in sync with existing code as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated @abdulrahuman5196 !

/>
)}

Expand Down
18 changes: 18 additions & 0 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,23 @@ const propTypes = {
/** Information about the network */
network: networkPropTypes.isRequired,

/** The policy object for the current route */
policy: PropTypes.shape({
/** The name of the policy */
name: PropTypes.string,

/** The URL for the policy avatar */
avatar: PropTypes.string,
}),

...windowDimensionsPropTypes,
...withDrawerPropTypes,
...withLocalizePropTypes,
};

const defaultProps = {
reportActions: [],
policy: null,
};

class ReportActionsView extends React.Component {
Expand Down Expand Up @@ -169,6 +179,14 @@ class ReportActionsView extends React.Component {
return true;
}

if (lodashGet(this.props, 'policy.avatar') !== lodashGet(nextProps, 'policy.avatar')) {
return true;
}

if (lodashGet(this.props, 'policy.name') !== lodashGet(nextProps, 'policy.name')) {
return true;
}

return !_.isEqual(lodashGet(this.props.report, 'icons', []), lodashGet(nextProps.report, 'icons', []));
}

Expand Down