2017-09-26 16:49:13 +03:00
|
|
|
/*
|
|
|
|
Copyright 2017 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-12-20 04:19:56 +03:00
|
|
|
import * as sdk from '../../../index';
|
2020-05-14 05:41:41 +03:00
|
|
|
import dis from '../../../dispatcher/dispatcher';
|
2017-09-26 16:49:13 +03:00
|
|
|
import { GroupRoomType } from '../../../groups';
|
2019-12-17 20:26:12 +03:00
|
|
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
2021-03-09 06:04:46 +03:00
|
|
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
2017-09-26 16:49:13 +03:00
|
|
|
|
2021-03-09 06:04:46 +03:00
|
|
|
@replaceableComponent("views.groups.GroupRoomTile")
|
2020-08-29 14:14:16 +03:00
|
|
|
class GroupRoomTile extends React.Component {
|
|
|
|
static propTypes = {
|
2017-09-26 16:49:13 +03:00
|
|
|
groupId: PropTypes.string.isRequired,
|
|
|
|
groupRoom: GroupRoomType.isRequired,
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static contextType = MatrixClientContext
|
2017-09-26 16:49:13 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
onClick = e => {
|
2017-09-26 16:49:13 +03:00
|
|
|
dis.dispatch({
|
2017-11-01 20:13:00 +03:00
|
|
|
action: 'view_group_room',
|
|
|
|
groupId: this.props.groupId,
|
2017-11-02 16:25:55 +03:00
|
|
|
groupRoomId: this.props.groupRoom.roomId,
|
2017-10-03 13:16:22 +03:00
|
|
|
});
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2017-09-29 19:59:24 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
render() {
|
2017-09-26 16:49:13 +03:00
|
|
|
const BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
|
|
|
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
2019-12-17 20:26:12 +03:00
|
|
|
const avatarUrl = this.context.mxcUrlToHttp(
|
2017-09-26 16:49:13 +03:00
|
|
|
this.props.groupRoom.avatarUrl,
|
|
|
|
36, 36, 'crop',
|
|
|
|
);
|
|
|
|
|
|
|
|
const av = (
|
2017-11-01 20:13:00 +03:00
|
|
|
<BaseAvatar name={this.props.groupRoom.displayname}
|
2017-09-26 16:49:13 +03:00
|
|
|
width={36} height={36}
|
|
|
|
url={avatarUrl}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AccessibleButton className="mx_GroupRoomTile" onClick={this.onClick}>
|
|
|
|
<div className="mx_GroupRoomTile_avatar">
|
2017-09-28 13:21:06 +03:00
|
|
|
{ av }
|
2017-09-26 16:49:13 +03:00
|
|
|
</div>
|
|
|
|
<div className="mx_GroupRoomTile_name">
|
2017-11-01 20:13:00 +03:00
|
|
|
{ this.props.groupRoom.displayname }
|
2017-09-26 16:49:13 +03:00
|
|
|
</div>
|
|
|
|
</AccessibleButton>
|
|
|
|
);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|
2017-09-26 16:49:13 +03:00
|
|
|
|
|
|
|
export default GroupRoomTile;
|