mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-15 15:21:31 +03:00
Save all events
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
c1fcadba3b
commit
8c67b96a0f
1 changed files with 9 additions and 4 deletions
|
@ -33,10 +33,14 @@ const SUPPORTED_STATES = [
|
|||
];
|
||||
|
||||
export default class CallEventGrouper extends EventEmitter {
|
||||
invite: MatrixEvent;
|
||||
events: Array<MatrixEvent> = [];
|
||||
call: MatrixCall;
|
||||
state: CallState;
|
||||
|
||||
private get invite(): MatrixEvent {
|
||||
return this.events.find((event) => event.getType() === EventType.CallInvite);
|
||||
}
|
||||
|
||||
public answerCall = () => {
|
||||
this.call?.answer();
|
||||
}
|
||||
|
@ -80,10 +84,11 @@ export default class CallEventGrouper extends EventEmitter {
|
|||
}
|
||||
|
||||
public add(event: MatrixEvent) {
|
||||
if (event.getType() === EventType.CallInvite) this.invite = event;
|
||||
if (event.getType() === EventType.CallHangup) this.state = CallState.Ended;
|
||||
this.events.push(event);
|
||||
const type = event.getType();
|
||||
|
||||
if (this.call) return;
|
||||
if (type === EventType.CallHangup) this.state = CallState.Ended;
|
||||
else if (type === EventType.CallReject) this.state = CallState.Ended;
|
||||
const callId = event.getContent().call_id;
|
||||
this.call = CallHandler.sharedInstance().getCallById(callId);
|
||||
if (!this.call) return;
|
||||
|
|
Loading…
Reference in a new issue