diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index 22939b2cc8..8b1dc41b07 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -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, { diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index 453663a261..3e07d617de 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -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...'); diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 2a6d0b5de8..8b90b6b810 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -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 { if (activeCall) { let zoomButton; let videoMuteButton; - if (activeCall.type === "video") { + if (activeCall.type === CallType.Video) { zoomButton = (