Migrate ViewSourceEvent to TypeScript

pull/21833/head
Germain Souquet 2021-07-22 17:11:23 +02:00
parent 6765bb8f4c
commit 0768f03097
3 changed files with 21 additions and 13 deletions

View File

@ -43,8 +43,10 @@ limitations under the License.
margin-bottom: 7px; margin-bottom: 7px;
mask-image: url('$(res)/img/feather-customised/minimise.svg'); mask-image: url('$(res)/img/feather-customised/minimise.svg');
} }
}
&:hover .mx_ViewSourceEvent_toggle { .mx_EventTile:hover {
.mx_ViewSourceEvent_toggle {
visibility: visible; visibility: visible;
} }
} }

View File

@ -219,13 +219,16 @@ limitations under the License.
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
.mx_EventTile_avatar { .mx_EventTile_avatar {
position: static; position: static;
order: -1; order: -1;
margin-right: 5px; margin-right: 5px;
} }
.mx_EventTile_e2eIcon {
margin-left: 9px;
}
} }
& ~ .mx_EventListSummary { & ~ .mx_EventListSummary {

View File

@ -15,18 +15,21 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import { MatrixEvent } from 'matrix-js-sdk/src';
import classNames from 'classnames'; import classNames from 'classnames';
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
@replaceableComponent("views.messages.ViewSourceEvent") interface IProps {
export default class ViewSourceEvent extends React.PureComponent { mxEvent: MatrixEvent;
static propTypes = { }
/* the MatrixEvent to show */
mxEvent: PropTypes.object.isRequired,
};
interface IState {
expanded: boolean;
}
@replaceableComponent("views.messages.ViewSourceEvent")
export default class ViewSourceEvent extends React.PureComponent<IProps, IState> {
constructor(props) { constructor(props) {
super(props); super(props);
@ -35,7 +38,7 @@ export default class ViewSourceEvent extends React.PureComponent {
}; };
} }
componentDidMount() { public componentDidMount(): void {
const { mxEvent } = this.props; const { mxEvent } = this.props;
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
@ -46,15 +49,15 @@ export default class ViewSourceEvent extends React.PureComponent {
} }
} }
onToggle = (ev) => { private onToggle = (ev: React.MouseEvent) => {
ev.preventDefault(); ev.preventDefault();
const { expanded } = this.state; const { expanded } = this.state;
this.setState({ this.setState({
expanded: !expanded, expanded: !expanded,
}); });
} };
render() { public render(): React.ReactNode {
const { mxEvent } = this.props; const { mxEvent } = this.props;
const { expanded } = this.state; const { expanded } = this.state;