Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a8487c5

Browse files
committed
Convert group avatar URL to HTTP before handing to BaseAvatar
This is yet another component that imports the MatrixClient just for mxcUrlToHttp. It'd be much nicer to have an avatar component that accepted MXCs, e.g. by wrapping or modifying BaseAvatar.
1 parent 9a6c959 commit a8487c5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/views/groups/GroupInviteTile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
import React from 'react';
1818
import PropTypes from 'prop-types';
19+
import { MatrixClient } from 'matrix-js-sdk';
1920
import sdk from '../../../index';
2021
import dis from '../../../dispatcher';
2122
import AccessibleButton from '../elements/AccessibleButton';
@@ -27,6 +28,10 @@ export default React.createClass({
2728
group: PropTypes.object.isRequired,
2829
},
2930

31+
contextTypes: {
32+
matrixClient: PropTypes.instanceOf(MatrixClient),
33+
},
34+
3035
onClick: function(e) {
3136
dis.dispatch({
3237
action: 'view_group',
@@ -39,8 +44,10 @@ export default React.createClass({
3944
const EmojiText = sdk.getComponent('elements.EmojiText');
4045

4146
const groupName = this.props.group.name || this.props.group.groupId;
47+
const httpAvatarUrl = this.props.group.avatarUrl ?
48+
this.context.matrixClient.mxcUrlToHttp(this.props.group.avatarUrl, 24, 24) : null;
4249

43-
const av = <BaseAvatar name={groupName} width={24} height={24} url={this.props.group.avatarUrl} />;
50+
const av = <BaseAvatar name={groupName} width={24} height={24} url={httpAvatarUrl} />;
4451

4552
const label = <EmojiText
4653
element="div"

0 commit comments

Comments
 (0)