diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index 8b1dc41b07..6b66a614d2 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, CallEvent, CallParty } from "matrix-js-sdk/lib/webrtc/call"; +import { MatrixCall, CallErrorCode, CallState, CallEvent, CallParty } from "matrix-js-sdk/lib/webrtc/call"; enum AudioID { Ring = 'ringAudio', @@ -86,6 +86,16 @@ enum AudioID { Busy = 'busyAudio', } +// Unlike 'CallType' in js-sdk, this one includes screen sharing +// (because a screen sharing call is only a screen sharing call to the caller, +// to the callee it's just a video call, at least as far as the current impl +// is concerned). +export enum PlaceCallType { + Voice = 'voice', + Video = 'video', + ScreenSharing = 'screensharing', +} + export default class CallHandler { private calls = new Map(); private audioPromises = new Map>(); @@ -271,18 +281,21 @@ export default class CallHandler { } - private placeCall(roomId: string, type: CallType, localElement: HTMLVideoElement, remoteElement: HTMLVideoElement) { + private placeCall( + roomId: string, type: PlaceCallType, + localElement: HTMLVideoElement, remoteElement: HTMLVideoElement, + ) { const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), roomId); this.calls.set(roomId, call); this.setCallListeners(call); - if (type === 'voice') { + if (type === PlaceCallType.Voice) { call.placeVoiceCall(); } else if (type === 'video') { call.placeVideoCall( remoteElement, localElement, ); - } else if (type === 'screensharing') { + } else if (type === PlaceCallType.ScreenSharing) { const screenCapErrorString = PlatformPeg.get().screenCaptureErrorString(); if (screenCapErrorString) { this.removeCallForRoom(roomId); diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 2ca1cc5aef..1708e2e7f1 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -37,6 +37,7 @@ import WidgetStore from "../../../stores/WidgetStore"; import WidgetUtils from "../../../utils/WidgetUtils"; import {UPDATE_EVENT} from "../../../stores/AsyncStore"; import ActiveWidgetStore from "../../../stores/ActiveWidgetStore"; +import { PlaceCallType } from "../../../CallHandler"; function ComposerAvatar(props) { const MemberStatusMessageAvatar = sdk.getComponent('avatars.MemberStatusMessageAvatar'); @@ -53,7 +54,7 @@ function CallButton(props) { const onVoiceCallClick = (ev) => { dis.dispatch({ action: 'place_call', - type: "voice", + type: PlaceCallType.Voice, room_id: props.roomId, }); }; @@ -73,7 +74,7 @@ function VideoCallButton(props) { const onCallClick = (ev) => { dis.dispatch({ action: 'place_call', - type: ev.shiftKey ? "screensharing" : "video", + type: ev.shiftKey ? PlaceCallType.ScreenSharing : PlaceCallType.Video, room_id: props.roomId, }); };