From 4ae92d8adc4b5d27695c3fccb0486f4c21bc0c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 30 May 2021 12:42:23 +0200 Subject: [PATCH] Hook up TimelineCallEventStore and add Avatar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- res/css/views/messages/_CallEvent.scss | 14 ++++-- src/components/structures/MessagePanel.js | 3 ++ src/components/views/messages/CallEvent.tsx | 54 ++++++++++++++++++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/res/css/views/messages/_CallEvent.scss b/res/css/views/messages/_CallEvent.scss index cc465555e8..dfff484734 100644 --- a/res/css/views/messages/_CallEvent.scss +++ b/res/css/views/messages/_CallEvent.scss @@ -16,7 +16,8 @@ limitations under the License. .mx_CallEvent { display: flex; - flex-direction: column; + flex-direction: row; + align-items: center; background-color: $dark-panel-bg-color; padding: 10px; @@ -25,9 +26,16 @@ limitations under the License. max-width: 75%; box-sizing: border-box; - .mx_CallEvent_sender {} + .mx_CallEvent_content { + display: flex; + flex-direction: column; - .mx_CallEvent_type { + .mx_CallEvent_sender { + } + + .mx_CallEvent_type { + + } } } diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index d1071a9e19..e2bb3135cf 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -26,6 +26,7 @@ import * as sdk from '../../index'; import {MatrixClientPeg} from '../../MatrixClientPeg'; import SettingsStore from '../../settings/SettingsStore'; +import TimelineCallEventStore from "../../stores/TimelineCallEventStore"; import {Layout, LayoutPropType} from "../../settings/Layout"; import {_t} from "../../languageHandler"; import {haveTileForEvent} from "../views/rooms/EventTile"; @@ -529,6 +530,8 @@ export default class MessagePanel extends React.Component { const last = (mxEv === lastShownEvent); const {nextEvent, nextTile} = this._getNextEventInfo(this.props.events, i); + TimelineCallEventStore.instance.addEvent(mxEv); + if (grouper) { if (grouper.shouldGroup(mxEv)) { grouper.add(mxEv); diff --git a/src/components/views/messages/CallEvent.tsx b/src/components/views/messages/CallEvent.tsx index 37a624222d..e8e6642776 100644 --- a/src/components/views/messages/CallEvent.tsx +++ b/src/components/views/messages/CallEvent.tsx @@ -18,16 +18,45 @@ import React from 'react'; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { _t } from '../../../languageHandler'; +import TimelineCallEventStore, { + TimelineCall as TimelineCallSt, + TimelineCallEventStoreEvent, + TimelineCallState, +} from "../../../stores/TimelineCallEventStore"; +import MemberAvatar from '../avatars/MemberAvatar'; interface IProps { mxEvent: MatrixEvent; } interface IState { - + callState: TimelineCallState; } -export default class RoomCreate extends React.Component { +export default class CallEvent extends React.Component { + constructor(props: IProps) { + super(props); + + this.state = { + callState: null, + } + } + + componentDidMount() { + TimelineCallEventStore.instance.addListener(TimelineCallEventStoreEvent.CallsChanged, this.onCallsChanged); + } + + componentWillUnmount() { + TimelineCallEventStore.instance.removeListener(TimelineCallEventStoreEvent.CallsChanged, this.onCallsChanged); + } + + private onCallsChanged = (calls: Map) => { + const callId = this.props.mxEvent.getContent().call_id; + const call = calls.get(callId); + if (!call) return; + this.setState({callState: call.state}); + } + private isVoice(): boolean { const event = this.props.mxEvent; @@ -44,14 +73,23 @@ export default class RoomCreate extends React.Component { render() { const event = this.props.mxEvent; const sender = event.sender ? event.sender.name : event.getSender(); + const state = this.state.callState; return ( -
-
- {sender} -
-
- { this.isVoice() ? _t("Voice call") : _t("Video call") } +
+ +
+
+ {sender} +
+
+ { this.isVoice() ? _t("Voice call") : _t("Video call") } + { state ? state : TimelineCallState.Unknown } +
);