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

View file

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

View file

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