Currently just by adding /holdcall and /unholdcall slash commands The only place the hold status of the call is currently represented is when the call is a voice call and you're viewing a different room: it's not wired up when you're viewing the room because that currently uses the room status bar which it won't do with the new UI. Also convert VideoFeed to typescript, and remove videoview because it essentially just managed the fullscreen functionality, but we'll want and 'on hold' representation (and probably chrome for hagnup etc) in the fullscreen UI too, so let's just make CallView the thing that gets fullscreened.
115 lines
3.4 KiB
TypeScript
115 lines
3.4 KiB
TypeScript
/*
|
|
Copyright 2017, 2018 New Vector Ltd
|
|
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import React from 'react';
|
|
|
|
import CallView from "./CallView";
|
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
|
import CallHandler from '../../../CallHandler';
|
|
import dis from '../../../dispatcher/dispatcher';
|
|
import { ActionPayload } from '../../../dispatcher/payloads';
|
|
import PersistentApp from "../elements/PersistentApp";
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
|
import { CallState, MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
|
|
|
|
interface IProps {
|
|
}
|
|
|
|
interface IState {
|
|
roomId: string;
|
|
activeCall: MatrixCall;
|
|
}
|
|
|
|
export default class CallPreview extends React.Component<IProps, IState> {
|
|
private roomStoreToken: any;
|
|
private dispatcherRef: string;
|
|
private settingsWatcherRef: string;
|
|
|
|
constructor(props: IProps) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
roomId: RoomViewStore.getRoomId(),
|
|
activeCall: CallHandler.sharedInstance().getAnyActiveCall(),
|
|
};
|
|
}
|
|
|
|
public componentDidMount() {
|
|
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
|
|
this.dispatcherRef = dis.register(this.onAction);
|
|
}
|
|
|
|
public componentWillUnmount() {
|
|
if (this.roomStoreToken) {
|
|
this.roomStoreToken.remove();
|
|
}
|
|
dis.unregister(this.dispatcherRef);
|
|
SettingsStore.unwatchSetting(this.settingsWatcherRef);
|
|
}
|
|
|
|
private onRoomViewStoreUpdate = (payload) => {
|
|
if (RoomViewStore.getRoomId() === this.state.roomId) return;
|
|
this.setState({
|
|
roomId: RoomViewStore.getRoomId(),
|
|
});
|
|
};
|
|
|
|
private onAction = (payload: ActionPayload) => {
|
|
switch (payload.action) {
|
|
// listen for call state changes to prod the render method, which
|
|
// may hide the global CallView if the call it is tracking is dead
|
|
case 'call_state':
|
|
this.setState({
|
|
activeCall: CallHandler.sharedInstance().getAnyActiveCall(),
|
|
});
|
|
break;
|
|
}
|
|
};
|
|
|
|
private onCallViewClick = () => {
|
|
const call = CallHandler.sharedInstance().getAnyActiveCall();
|
|
if (call) {
|
|
dis.dispatch({
|
|
action: 'view_room',
|
|
room_id: call.roomId,
|
|
});
|
|
}
|
|
};
|
|
|
|
public render() {
|
|
const callForRoom = CallHandler.sharedInstance().getCallForRoom(this.state.roomId);
|
|
const showCall = (
|
|
this.state.activeCall &&
|
|
this.state.activeCall.state === CallState.Connected &&
|
|
!callForRoom
|
|
);
|
|
|
|
if (showCall) {
|
|
return (
|
|
<CallView
|
|
className="mx_CallPreview"
|
|
onClick={this.onCallViewClick}
|
|
showHangup={true}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return <PersistentApp />;
|
|
}
|
|
}
|
|
|