Migrate ViewSourceEvent to TypeScript
This commit is contained in:
parent
6868478044
commit
cf3117bd57
1 changed files with 15 additions and 13 deletions
|
@ -15,27 +15,29 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
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";
|
||||||
|
import { MatrixEvent } from '../../../../../matrix-js-sdk/src';
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
mxEvent: MatrixEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IState {
|
||||||
|
expanded: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.messages.ViewSourceEvent")
|
@replaceableComponent("views.messages.ViewSourceEvent")
|
||||||
export default class ViewSourceEvent extends React.PureComponent {
|
export default class ViewSourceEvent extends React.PureComponent<IProps, IState> {
|
||||||
static propTypes = {
|
constructor(props: IProps) {
|
||||||
/* the MatrixEvent to show */
|
|
||||||
mxEvent: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
expanded: false,
|
expanded: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
public componentDidMount(): void {
|
||||||
const { mxEvent } = this.props;
|
const { mxEvent } = this.props;
|
||||||
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
|
@ -46,15 +48,15 @@ export default class ViewSourceEvent extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggle = (ev) => {
|
private onToggle = (ev: React.MouseEvent): void => {
|
||||||
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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue