mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-15 20:41:30 +03:00
Simply use call states
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
6b72c13e34
commit
f96e25d833
2 changed files with 6 additions and 17 deletions
|
@ -21,16 +21,6 @@ import { CallEvent, CallState, MatrixCall } from "matrix-js-sdk/src/webrtc/call"
|
||||||
import CallHandler from '../../CallHandler';
|
import CallHandler from '../../CallHandler';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
export enum CallEventGrouperState {
|
|
||||||
Incoming = "incoming",
|
|
||||||
Connecting = "connecting",
|
|
||||||
Connected = "connected",
|
|
||||||
Ringing = "ringing",
|
|
||||||
Missed = "missed",
|
|
||||||
Rejected = "rejected",
|
|
||||||
Ended = "ended",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum CallEventGrouperEvent {
|
export enum CallEventGrouperEvent {
|
||||||
StateChanged = "state_changed",
|
StateChanged = "state_changed",
|
||||||
}
|
}
|
||||||
|
@ -38,7 +28,7 @@ export enum CallEventGrouperEvent {
|
||||||
export default class CallEventGrouper extends EventEmitter {
|
export default class CallEventGrouper extends EventEmitter {
|
||||||
invite: MatrixEvent;
|
invite: MatrixEvent;
|
||||||
call: MatrixCall;
|
call: MatrixCall;
|
||||||
state: CallEventGrouperState;
|
state: CallState;
|
||||||
|
|
||||||
public answerCall = () => {
|
public answerCall = () => {
|
||||||
this.call?.answer();
|
this.call?.answer();
|
||||||
|
@ -76,9 +66,7 @@ export default class CallEventGrouper extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setCallState = () => {
|
private setCallState = () => {
|
||||||
if (this.call?.state === CallState.Ringing) {
|
this.state = this.call.state
|
||||||
this.state = CallEventGrouperState.Incoming;
|
|
||||||
}
|
|
||||||
this.emit(CallEventGrouperEvent.StateChanged, this.state);
|
this.emit(CallEventGrouperEvent.StateChanged, this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ import React from 'react';
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import MemberAvatar from '../avatars/MemberAvatar';
|
import MemberAvatar from '../avatars/MemberAvatar';
|
||||||
import CallEventGrouper, { CallEventGrouperEvent, CallEventGrouperState } from '../../structures/CallEventGrouper';
|
import CallEventGrouper, { CallEventGrouperEvent } from '../../structures/CallEventGrouper';
|
||||||
import FormButton from '../elements/FormButton';
|
import FormButton from '../elements/FormButton';
|
||||||
|
import { CallState } from 'matrix-js-sdk/src/webrtc/call';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
mxEvent: MatrixEvent;
|
mxEvent: MatrixEvent;
|
||||||
|
@ -28,7 +29,7 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
callState: CallEventGrouperState;
|
callState: CallState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class CallEvent extends React.Component<IProps, IState> {
|
export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
|
@ -57,7 +58,7 @@ export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
const sender = event.sender ? event.sender.name : event.getSender();
|
const sender = event.sender ? event.sender.name : event.getSender();
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
if (this.state.callState === CallEventGrouperState.Incoming) {
|
if (this.state.callState === CallState.Ringing) {
|
||||||
content = (
|
content = (
|
||||||
<div className="mx_CallEvent_content">
|
<div className="mx_CallEvent_content">
|
||||||
<FormButton
|
<FormButton
|
||||||
|
|
Loading…
Reference in a new issue