Another rewrite

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-06-01 09:30:37 +02:00
parent 8eb24d0d74
commit dac741d8b9
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
5 changed files with 124 additions and 66 deletions

View file

@ -19,15 +19,39 @@ import React from 'react';
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { _t } from '../../../languageHandler';
import MemberAvatar from '../avatars/MemberAvatar';
import { TimelineCallState } from '../../structures/CallEventGrouper';
import CallEventGrouper, { CallEventGrouperEvent, CallEventGrouperState } from '../../structures/CallEventGrouper';
import FormButton from '../elements/FormButton';
interface IProps {
mxEvent: MatrixEvent;
timelineCallState: TimelineCallState;
}
callEventGrouper: CallEventGrouper;
}
export default class CallEvent extends React.Component<IProps> {
interface IState {
callState: CallEventGrouperState;
}
export default class CallEvent extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props);
this.state = {
callState: this.props.callEventGrouper.getState(),
}
}
componentDidMount() {
this.props.callEventGrouper.addListener(CallEventGrouperEvent.StateChanged, this.onStateChanged);
}
componentWillUnmount() {
this.props.callEventGrouper.removeListener(CallEventGrouperEvent.StateChanged, this.onStateChanged);
}
private onStateChanged = (newState: CallEventGrouperState) => {
this.setState({callState: newState});
}
render() {
const event = this.props.mxEvent;
const sender = event.sender ? event.sender.name : event.getSender();
@ -47,7 +71,7 @@ export default class CallEvent extends React.Component<IProps> {
{ sender }
</div>
<div className="mx_CallEvent_type">
{ this.props.timelineCallState.isVoice ? _t("Voice call") : _t("Video call") }
{ this.props.callEventGrouper.isVoice() ? _t("Voice call") : _t("Video call") }
</div>
</div>
</div>

View file

@ -46,7 +46,7 @@ import { EditorStateTransfer } from "../../../utils/EditorStateTransfer";
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
import {StaticNotificationState} from "../../../stores/notifications/StaticNotificationState";
import NotificationBadge from "./NotificationBadge";
import { TimelineCallState } from "../../structures/CallEventGrouper";
import CallEventGrouper from "../../structures/CallEventGrouper";
const eventTileTypes = {
[EventType.RoomMessage]: 'messages.MessageEvent',
@ -277,7 +277,7 @@ interface IProps {
permalinkCreator?: RoomPermalinkCreator;
// CallEventGrouper for this event
callState?: TimelineCallState;
callEventGrouper?: CallEventGrouper;
}
interface IState {
@ -1143,7 +1143,7 @@ export default class EventTile extends React.Component<IProps, IState> {
showUrlPreview={this.props.showUrlPreview}
permalinkCreator={this.props.permalinkCreator}
onHeightChanged={this.props.onHeightChanged}
callState={this.props.callState}
callEventGrouper={this.props.callEventGrouper}
/>
{ keyRequestInfo }
{ reactionsRow }