Rename profile object properties to camelCase

Also, add correct PropTypes for FlairAvatar
pull/21833/head
Luke Barnard 2017-09-21 14:22:43 +01:00
parent e64cc3b666
commit 41a9ff22fb
1 changed files with 11 additions and 5 deletions

View File

@ -121,8 +121,11 @@ async function getGroupProfileCached(matrixClient, groupId) {
return groupProfiles[groupId]; return groupProfiles[groupId];
} }
groupProfiles[groupId] = await matrixClient.getGroupProfile(groupId); const profile = await matrixClient.getGroupProfile(groupId);
groupProfiles[groupId].group_id = groupId; groupProfiles[groupId] = {
groupId,
avatarUrl: profile.avatar_url,
};
return groupProfiles[groupId]; return groupProfiles[groupId];
} }
@ -139,19 +142,22 @@ class FlairAvatar extends React.Component {
ev.stopPropagation(); ev.stopPropagation();
dis.dispatch({ dis.dispatch({
action: 'view_group', action: 'view_group',
group_id: this.props.groupProfile.group_id, group_id: this.props.groupProfile.groupId,
}); });
} }
render() { render() {
const httpUrl = this.context.matrixClient.mxcUrlToHttp( const httpUrl = this.context.matrixClient.mxcUrlToHttp(
this.props.groupProfile.avatar_url, 14, 14, 'scale', false); this.props.groupProfile.avatarUrl, 14, 14, 'scale', false);
return <img src={httpUrl} width="14px" height="14px" onClick={this.onClick}/>; return <img src={httpUrl} width="14px" height="14px" onClick={this.onClick}/>;
} }
} }
FlairAvatar.propTypes = { FlairAvatar.propTypes = {
groupProfile: PropTypes.string, groupProfile: PropTypes.shape({
groupId: PropTypes.string.isRequired,
avatarUrl: PropTypes.string.isRequired,
}),
}; };
FlairAvatar.contextTypes = { FlairAvatar.contextTypes = {