1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Improve TypeScript in MatrixCall

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-08-28 09:27:47 +02:00
parent b97e3113d1
commit 411fc47f28
2 changed files with 129 additions and 132 deletions

View File

@@ -19,6 +19,7 @@ import { logger } from '../logger';
import { createNewMatrixCall, MatrixCall, CallErrorCode, CallState, CallDirection } from './call';
import { EventType } from '../@types/event';
import { MatrixClient } from '../client';
import { MCallAnswer, MCallHangupReject } from "./callEventTypes";
// Don't ring unless we'd be ringing for at least 3 seconds: the user needs some
// time to press the 'accept' button
@@ -252,9 +253,9 @@ export class CallEventHandler {
} else {
if (call.state !== CallState.Ended) {
if (type === EventType.CallHangup) {
call.onHangupReceived(content);
call.onHangupReceived(content as MCallHangupReject);
} else {
call.onRejectReceived(content);
call.onRejectReceived(content as MCallHangupReject);
}
this.calls.delete(content.call_id);
}
@@ -274,7 +275,7 @@ export class CallEventHandler {
case EventType.CallAnswer:
if (weSentTheEvent) {
if (call.state === CallState.Ringing) {
call.onAnsweredElsewhere(content);
call.onAnsweredElsewhere(content as MCallAnswer);
}
} else {
call.onAnswerReceived(event);