1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-07 10:46:24 +03:00

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, {