More enums

This commit is contained in:
David Baker 2020-10-12 10:25:23 +01:00
parent 3af7abb5fe
commit abd5e3b3cf
3 changed files with 18 additions and 17 deletions

View file

@ -77,7 +77,7 @@ import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import WidgetStore from "./stores/WidgetStore"; import WidgetStore from "./stores/WidgetStore";
import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore"; import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore";
import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions"; import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions";
import { MatrixCall, CallErrorCode, CallState, CallType } from "matrix-js-sdk/lib/webrtc/call"; import { MatrixCall, CallErrorCode, CallState, CallType, CallEvent, CallParty } from "matrix-js-sdk/lib/webrtc/call";
enum AudioID { enum AudioID {
Ring = 'ringAudio', Ring = 'ringAudio',
@ -119,7 +119,7 @@ export default class CallHandler {
getAnyActiveCall() { getAnyActiveCall() {
for (const call of this.calls.values()) { for (const call of this.calls.values()) {
if (call.state !== "ended") { if (call.state !== CallState.Ended) {
return call; return call;
} }
} }
@ -170,7 +170,7 @@ export default class CallHandler {
} }
private setCallListeners(call: MatrixCall) { private setCallListeners(call: MatrixCall) {
call.on("error", (err) => { call.on(CallEvent.Error, (err) => {
console.error("Call error:", err); console.error("Call error:", err);
if ( if (
MatrixClientPeg.get().getTurnServers().length === 0 && MatrixClientPeg.get().getTurnServers().length === 0 &&
@ -185,10 +185,10 @@ export default class CallHandler {
description: err.message, description: err.message,
}); });
}); });
call.on("hangup", () => { call.on(CallEvent.Hangup, () => {
this.removeCallForRoom(call.roomId); this.removeCallForRoom(call.roomId);
}); });
call.on("state", (newState: CallState, oldState: CallState) => { call.on(CallEvent.State, (newState: CallState, oldState: CallState) => {
this.setCallState(call, newState); this.setCallState(call, newState);
switch (oldState) { switch (oldState) {
@ -210,8 +210,8 @@ export default class CallHandler {
case CallState.Ended: case CallState.Ended:
this.removeCallForRoom(call.roomId); this.removeCallForRoom(call.roomId);
if (oldState === CallState.InviteSent && ( if (oldState === CallState.InviteSent && (
call.hangupParty === "remote" || call.hangupParty === CallParty.Remote ||
(call.hangupParty === "local" && call.hangupReason === "invite_timeout") (call.hangupParty === CallParty.Local && call.hangupReason === CallErrorCode.InviteTimeout)
)) { )) {
this.play(AudioID.Busy); this.play(AudioID.Busy);
Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, {

View file

@ -24,6 +24,7 @@ import Resend from '../../Resend';
import dis from '../../dispatcher/dispatcher'; import dis from '../../dispatcher/dispatcher';
import {messageForResourceLimitError, messageForSendError} from '../../utils/ErrorUtils'; import {messageForResourceLimitError, messageForSendError} from '../../utils/ErrorUtils';
import {Action} from "../../dispatcher/actions"; import {Action} from "../../dispatcher/actions";
import { CallState, CallType } from 'matrix-js-sdk/lib/webrtc/call';
const STATUS_BAR_HIDDEN = 0; const STATUS_BAR_HIDDEN = 0;
const STATUS_BAR_EXPANDED = 1; const STATUS_BAR_EXPANDED = 1;
@ -122,7 +123,7 @@ export default class RoomStatusBar extends React.Component {
}; };
_showCallBar() { _showCallBar() {
return this.props.callState !== 'ended' && this.props.callState !== 'ringing'; return this.props.callState !== CallState.Ended && this.props.callState !== CallState.Ringing;
} }
_onResendAllClick = () => { _onResendAllClick = () => {
@ -275,16 +276,16 @@ export default class RoomStatusBar extends React.Component {
_getCallStatusText() { _getCallStatusText() {
switch (this.props.callState) { switch (this.props.callState) {
case 'create_offer': case CallState.CreateOffer:
case 'invite_sent': case CallState.InviteSent:
return _t('Calling...'); return _t('Calling...');
case 'connecting': case CallState.Connecting:
case 'create_answer': case CallState.CreateAnswer:
return _t('Call connecting...'); return _t('Call connecting...');
case 'connected': case CallState.Connected:
return _t('Active call'); return _t('Active call');
case 'wait_local_media': case CallState.WaitLocalMedia:
if (this.props.callType === 'video') { if (this.props.callType === CallType.Video) {
return _t('Starting camera...'); return _t('Starting camera...');
} else { } else {
return _t('Starting microphone...'); return _t('Starting microphone...');

View file

@ -71,7 +71,7 @@ import RoomHeader from "../views/rooms/RoomHeader";
import TintableSvg from "../views/elements/TintableSvg"; import TintableSvg from "../views/elements/TintableSvg";
import {XOR} from "../../@types/common"; import {XOR} from "../../@types/common";
import { IThreepidInvite } from "../../stores/ThreepidInviteStore"; import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
import { CallState, MatrixCall } from "matrix-js-sdk/lib/webrtc/call"; import { CallState, CallType, MatrixCall } from "matrix-js-sdk/lib/webrtc/call";
const DEBUG = false; const DEBUG = false;
let debuglog = function(msg: string) {}; let debuglog = function(msg: string) {};
@ -1892,7 +1892,7 @@ export default class RoomView extends React.Component<IProps, IState> {
if (activeCall) { if (activeCall) {
let zoomButton; let videoMuteButton; let zoomButton; let videoMuteButton;
if (activeCall.type === "video") { if (activeCall.type === CallType.Video) {
zoomButton = ( zoomButton = (
<div className="mx_RoomView_voipButton" onClick={this.onFullscreenClick} title={_t("Fill screen")}> <div className="mx_RoomView_voipButton" onClick={this.onFullscreenClick} title={_t("Fill screen")}>
<TintableSvg <TintableSvg