1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-05 23:10:41 +03:00

Manage some more call states

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-06-01 10:33:44 +02:00
parent f96e25d833
commit c1fcadba3b
2 changed files with 33 additions and 4 deletions

View File

@@ -25,6 +25,13 @@ export enum CallEventGrouperEvent {
StateChanged = "state_changed",
}
const SUPPORTED_STATES = [
CallState.Connected,
CallState.Connecting,
CallState.Ended,
CallState.Ringing,
];
export default class CallEventGrouper extends EventEmitter {
invite: MatrixEvent;
call: MatrixCall;
@@ -66,12 +73,15 @@ export default class CallEventGrouper extends EventEmitter {
}
private setCallState = () => {
this.state = this.call.state
this.emit(CallEventGrouperEvent.StateChanged, this.state);
if (SUPPORTED_STATES.includes(this.call.state)) {
this.state = this.call.state;
this.emit(CallEventGrouperEvent.StateChanged, this.state);
}
}
public add(event: MatrixEvent) {
if (event.getType() === EventType.CallInvite) this.invite = event;
if (event.getType() === EventType.CallHangup) this.state = CallState.Ended;
if (this.call) return;
const callId = event.getContent().call_id;