Use CallChangeRoom in CallViewForRoom

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-04-28 11:56:26 +02:00
parent 40748d3c94
commit 653591e806
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -16,13 +16,12 @@ limitations under the License.
import { CallState, MatrixCall } from 'matrix-js-sdk/src/webrtc/call'; import { CallState, MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
import React from 'react'; import React from 'react';
import CallHandler from '../../../CallHandler'; import CallHandler, { CallHandlerEvent } from '../../../CallHandler';
import CallView from './CallView'; import CallView from './CallView';
import dis from '../../../dispatcher/dispatcher'; import dis from '../../../dispatcher/dispatcher';
import {Resizable} from "re-resizable"; import {Resizable} from "re-resizable";
import ResizeNotifier from "../../../utils/ResizeNotifier"; import ResizeNotifier from "../../../utils/ResizeNotifier";
import {replaceableComponent} from "../../../utils/replaceableComponent"; import {replaceableComponent} from "../../../utils/replaceableComponent";
import { Action } from '../../../dispatcher/actions';
interface IProps { interface IProps {
// What room we should display the call for // What room we should display the call for
@ -55,23 +54,28 @@ export default class CallViewForRoom extends React.Component<IProps, IState> {
public componentDidMount() { public componentDidMount() {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
CallHandler.sharedInstance().addListener(CallHandlerEvent.CallChangeRoom, this.updateCall);
} }
public componentWillUnmount() { public componentWillUnmount() {
dis.unregister(this.dispatcherRef); dis.unregister(this.dispatcherRef);
CallHandler.sharedInstance().removeListener(CallHandlerEvent.CallChangeRoom, this.updateCall);
} }
private onAction = (payload) => { private onAction = (payload) => {
switch (payload.action) { switch (payload.action) {
case Action.CallChangeRoom:
case 'call_state': { case 'call_state': {
this.updateCall();
break;
}
}
};
private updateCall = () => {
const newCall = this.getCall(); const newCall = this.getCall();
if (newCall !== this.state.call) { if (newCall !== this.state.call) {
this.setState({call: newCall}); this.setState({call: newCall});
} }
break;
}
}
}; };
private getCall(): MatrixCall { private getCall(): MatrixCall {