Rewrite call state machine
* Remove the two separate enumerations of call state: now everything uses the js-sdk version of call state. Stop adding a separate 'call_state' field onto the call object(!) * Better reflection of the actual state of the call in the call bar, so when it's connecting, it says connecting, and only says 'active call' when the call is actually active. * More typey goodness
This commit is contained in:
parent
5a4ca4578a
commit
55f77b04ae
8 changed files with 153 additions and 130 deletions
|
@ -71,6 +71,7 @@ import RoomHeader from "../views/rooms/RoomHeader";
|
|||
import TintableSvg from "../views/elements/TintableSvg";
|
||||
import {XOR} from "../../@types/common";
|
||||
import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
|
||||
import { CallState, MatrixCall } from "matrix-js-sdk/lib/webrtc/call";
|
||||
|
||||
const DEBUG = false;
|
||||
let debuglog = function(msg: string) {};
|
||||
|
@ -141,7 +142,7 @@ export interface IState {
|
|||
}>;
|
||||
searchHighlights?: string[];
|
||||
searchInProgress?: boolean;
|
||||
callState?: string;
|
||||
callState?: CallState;
|
||||
guestsCanJoin: boolean;
|
||||
canPeek: boolean;
|
||||
showApps: boolean;
|
||||
|
@ -479,7 +480,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
|
||||
componentDidMount() {
|
||||
const call = this.getCallForRoom();
|
||||
const callState = call ? call.call_state : "ended";
|
||||
const callState = call ? call.state : null;
|
||||
this.setState({
|
||||
callState: callState,
|
||||
});
|
||||
|
@ -712,14 +713,9 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
const call = this.getCallForRoom();
|
||||
let callState = "ended";
|
||||
|
||||
if (call) {
|
||||
callState = call.call_state;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
callState: callState,
|
||||
callState: call ? call.state : null,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -1605,7 +1601,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
/**
|
||||
* get any current call for this room
|
||||
*/
|
||||
private getCallForRoom() {
|
||||
private getCallForRoom(): MatrixCall {
|
||||
if (!this.state.room) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1742,10 +1738,12 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
// We have successfully loaded this room, and are not previewing.
|
||||
// Display the "normal" room view.
|
||||
|
||||
const call = this.getCallForRoom();
|
||||
let inCall = false;
|
||||
if (call && (this.state.callState !== 'ended' && this.state.callState !== 'ringing')) {
|
||||
inCall = true;
|
||||
let activeCall = null;
|
||||
{
|
||||
const call = this.getCallForRoom();
|
||||
if (call && (this.state.callState !== 'ended' && this.state.callState !== 'ringing')) {
|
||||
activeCall = call;
|
||||
}
|
||||
}
|
||||
|
||||
const scrollheaderClasses = classNames({
|
||||
|
@ -1764,7 +1762,8 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
statusBar = <RoomStatusBar
|
||||
room={this.state.room}
|
||||
sentMessageAndIsAlone={this.state.isAlone}
|
||||
hasActiveCall={inCall}
|
||||
callState={this.state.callState}
|
||||
callType={activeCall ? activeCall.type : null}
|
||||
isPeeking={myMembership !== "join"}
|
||||
onInviteClick={this.onInviteButtonClick}
|
||||
onStopWarningClick={this.onStopAloneWarningClick}
|
||||
|
@ -1890,10 +1889,10 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
if (inCall) {
|
||||
if (activeCall) {
|
||||
let zoomButton; let videoMuteButton;
|
||||
|
||||
if (call.type === "video") {
|
||||
if (activeCall.type === "video") {
|
||||
zoomButton = (
|
||||
<div className="mx_RoomView_voipButton" onClick={this.onFullscreenClick} title={_t("Fill screen")}>
|
||||
<TintableSvg
|
||||
|
@ -1908,10 +1907,11 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
videoMuteButton =
|
||||
<div className="mx_RoomView_voipButton" onClick={this.onMuteVideoClick}>
|
||||
<TintableSvg
|
||||
src={call.isLocalVideoMuted() ?
|
||||
src={activeCall.isLocalVideoMuted() ?
|
||||
require("../../../res/img/element-icons/call/video-muted.svg") :
|
||||
require("../../../res/img/element-icons/call/video-call.svg")}
|
||||
alt={call.isLocalVideoMuted() ? _t("Click to unmute video") : _t("Click to mute video")}
|
||||
alt={activeCall.isLocalVideoMuted() ? _t("Click to unmute video") :
|
||||
_t("Click to mute video")}
|
||||
width=""
|
||||
height="27"
|
||||
/>
|
||||
|
@ -1920,10 +1920,10 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
const voiceMuteButton =
|
||||
<div className="mx_RoomView_voipButton" onClick={this.onMuteAudioClick}>
|
||||
<TintableSvg
|
||||
src={call.isMicrophoneMuted() ?
|
||||
src={activeCall.isMicrophoneMuted() ?
|
||||
require("../../../res/img/element-icons/call/voice-muted.svg") :
|
||||
require("../../../res/img/element-icons/call/voice-unmuted.svg")}
|
||||
alt={call.isMicrophoneMuted() ? _t("Click to unmute audio") : _t("Click to mute audio")}
|
||||
alt={activeCall.isMicrophoneMuted() ? _t("Click to unmute audio") : _t("Click to mute audio")}
|
||||
width="21"
|
||||
height="26"
|
||||
/>
|
||||
|
@ -2041,7 +2041,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
});
|
||||
|
||||
const mainClasses = classNames("mx_RoomView", {
|
||||
mx_RoomView_inCall: inCall,
|
||||
mx_RoomView_inCall: Boolean(activeCall),
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue