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
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
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;