mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
Convert RoomAvatarEvent to TS
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
ff1c1fbc78
commit
421fa1ab69
1 changed files with 11 additions and 12 deletions
|
@ -17,23 +17,24 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import * as sdk from '../../../index';
|
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { mediaFromMxc } from "../../../customisations/Media";
|
import { mediaFromMxc } from "../../../customisations/Media";
|
||||||
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
import RoomAvatar from "../avatars/RoomAvatar";
|
||||||
|
import ImageView from "../elements/ImageView";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
/* the MatrixEvent to show */
|
||||||
|
mxEvent: MatrixEvent;
|
||||||
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.messages.RoomAvatarEvent")
|
@replaceableComponent("views.messages.RoomAvatarEvent")
|
||||||
export default class RoomAvatarEvent extends React.Component {
|
export default class RoomAvatarEvent extends React.Component<IProps> {
|
||||||
static propTypes = {
|
private onAvatarClick = (): void => {
|
||||||
/* the MatrixEvent to show */
|
|
||||||
mxEvent: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
onAvatarClick = () => {
|
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const ev = this.props.mxEvent;
|
const ev = this.props.mxEvent;
|
||||||
const httpUrl = mediaFromMxc(ev.getContent().url).srcHttp;
|
const httpUrl = mediaFromMxc(ev.getContent().url).srcHttp;
|
||||||
|
@ -44,7 +45,6 @@ export default class RoomAvatarEvent extends React.Component {
|
||||||
roomName: room ? room.name : '',
|
roomName: room ? room.name : '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const ImageView = sdk.getComponent("elements.ImageView");
|
|
||||||
const params = {
|
const params = {
|
||||||
src: httpUrl,
|
src: httpUrl,
|
||||||
name: text,
|
name: text,
|
||||||
|
@ -52,10 +52,9 @@ export default class RoomAvatarEvent extends React.Component {
|
||||||
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox", null, true);
|
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox", null, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
const ev = this.props.mxEvent;
|
const ev = this.props.mxEvent;
|
||||||
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
|
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
|
||||||
const RoomAvatar = sdk.getComponent("avatars.RoomAvatar");
|
|
||||||
|
|
||||||
if (!ev.getContent().url || ev.getContent().url.trim().length === 0) {
|
if (!ev.getContent().url || ev.getContent().url.trim().length === 0) {
|
||||||
return (
|
return (
|
Loading…
Reference in a new issue