You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Properly listen for call_state
The previous thing should have never worked, since CallsChanged doesn't get emitted when a call is answered Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
		@@ -55,7 +55,7 @@ import { getKeyBindingsManager, NavigationAction, RoomAction } from '../../KeyBi
 | 
				
			|||||||
import { IOpts } from "../../createRoom";
 | 
					import { IOpts } from "../../createRoom";
 | 
				
			||||||
import SpacePanel from "../views/spaces/SpacePanel";
 | 
					import SpacePanel from "../views/spaces/SpacePanel";
 | 
				
			||||||
import { replaceableComponent } from "../../utils/replaceableComponent";
 | 
					import { replaceableComponent } from "../../utils/replaceableComponent";
 | 
				
			||||||
import CallHandler, { CallHandlerEvent } from '../../CallHandler';
 | 
					import CallHandler from '../../CallHandler';
 | 
				
			||||||
import { MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
 | 
					import { MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
 | 
				
			||||||
import AudioFeedArrayForCall from '../views/voip/AudioFeedArrayForCall';
 | 
					import AudioFeedArrayForCall from '../views/voip/AudioFeedArrayForCall';
 | 
				
			||||||
import RoomView from './RoomView';
 | 
					import RoomView from './RoomView';
 | 
				
			||||||
@@ -142,6 +142,7 @@ interface IState {
 | 
				
			|||||||
class LoggedInView extends React.Component<IProps, IState> {
 | 
					class LoggedInView extends React.Component<IProps, IState> {
 | 
				
			||||||
    static displayName = 'LoggedInView';
 | 
					    static displayName = 'LoggedInView';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private dispatcherRef: string;
 | 
				
			||||||
    protected readonly _matrixClient: MatrixClient;
 | 
					    protected readonly _matrixClient: MatrixClient;
 | 
				
			||||||
    protected readonly _roomView: React.RefObject<any>;
 | 
					    protected readonly _roomView: React.RefObject<any>;
 | 
				
			||||||
    protected readonly _resizeContainer: React.RefObject<ResizeHandle>;
 | 
					    protected readonly _resizeContainer: React.RefObject<ResizeHandle>;
 | 
				
			||||||
@@ -172,7 +173,7 @@ class LoggedInView extends React.Component<IProps, IState> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    componentDidMount() {
 | 
					    componentDidMount() {
 | 
				
			||||||
        document.addEventListener('keydown', this.onNativeKeyDown, false);
 | 
					        document.addEventListener('keydown', this.onNativeKeyDown, false);
 | 
				
			||||||
        CallHandler.sharedInstance().addListener(CallHandlerEvent.CallsChanged, this.onCallsChanged);
 | 
					        this.dispatcherRef = dis.register(this.onAction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.updateServerNoticeEvents();
 | 
					        this.updateServerNoticeEvents();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -197,7 +198,7 @@ class LoggedInView extends React.Component<IProps, IState> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    componentWillUnmount() {
 | 
					    componentWillUnmount() {
 | 
				
			||||||
        document.removeEventListener('keydown', this.onNativeKeyDown, false);
 | 
					        document.removeEventListener('keydown', this.onNativeKeyDown, false);
 | 
				
			||||||
        CallHandler.sharedInstance().removeListener(CallHandlerEvent.CallsChanged, this.onCallsChanged);
 | 
					        dis.unregister(this.dispatcherRef);
 | 
				
			||||||
        this._matrixClient.removeListener("accountData", this.onAccountData);
 | 
					        this._matrixClient.removeListener("accountData", this.onAccountData);
 | 
				
			||||||
        this._matrixClient.removeListener("sync", this.onSync);
 | 
					        this._matrixClient.removeListener("sync", this.onSync);
 | 
				
			||||||
        this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);
 | 
					        this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);
 | 
				
			||||||
@@ -205,10 +206,16 @@ class LoggedInView extends React.Component<IProps, IState> {
 | 
				
			|||||||
        this.resizer.detach();
 | 
					        this.resizer.detach();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private onCallsChanged = () => {
 | 
					    private onAction = (payload): void => {
 | 
				
			||||||
        this.setState({
 | 
					        switch (payload.action) {
 | 
				
			||||||
            activeCalls: CallHandler.sharedInstance().getAllActiveCalls(),
 | 
					            case 'call_state': {
 | 
				
			||||||
        });
 | 
					                const activeCalls = CallHandler.sharedInstance().getAllActiveCalls();
 | 
				
			||||||
 | 
					                if (activeCalls !== this.state.activeCalls) {
 | 
				
			||||||
 | 
					                    this.setState({ activeCalls });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public canResetTimelineInRoom = (roomId: string) => {
 | 
					    public canResetTimelineInRoom = (roomId: string) => {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user