From faf2922b1b5b463feaa568f46a458167fd2f05a2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 4 Dec 2020 19:41:48 +0000 Subject: [PATCH] Update video element when the call changes in a videoview Because that can happen now --- src/components/views/voip/VideoFeed.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/views/voip/VideoFeed.tsx b/src/components/views/voip/VideoFeed.tsx index 5fb71a6d69..5210f28eb1 100644 --- a/src/components/views/voip/VideoFeed.tsx +++ b/src/components/views/voip/VideoFeed.tsx @@ -42,10 +42,12 @@ export default class VideoFeed extends React.Component { componentDidMount() { this.vid.current.addEventListener('resize', this.onResize); - if (this.props.type === VideoFeedType.Local) { - this.props.call.setLocalVideoElement(this.vid.current); - } else { - this.props.call.setRemoteVideoElement(this.vid.current); + this.setVideoElement(); + } + + componentDidUpdate(prevProps) { + if (this.props.call !== prevProps.call) { + this.setVideoElement(); } } @@ -53,6 +55,14 @@ export default class VideoFeed extends React.Component { this.vid.current.removeEventListener('resize', this.onResize); } + private setVideoElement() { + if (this.props.type === VideoFeedType.Local) { + this.props.call.setLocalVideoElement(this.vid.current); + } else { + this.props.call.setRemoteVideoElement(this.vid.current); + } + } + onResize = (e) => { if (this.props.onResize) { this.props.onResize(e);