From 90f4ad7a830e2f7c4c4150d2d0f6b83fcc6c311c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 10 May 2021 13:21:02 +0200 Subject: [PATCH] Always sort feeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/voip/CallView.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/views/voip/CallView.tsx b/src/components/views/voip/CallView.tsx index 0b3e1d5f48..a7ad6ef8c6 100644 --- a/src/components/views/voip/CallView.tsx +++ b/src/components/views/voip/CallView.tsx @@ -128,7 +128,7 @@ export default class CallView extends React.Component { controlsVisible: true, showMoreMenu: false, showDialpad: false, - feeds: this.props.call.getFeeds(), + feeds: this.sortFeeds(this.props.call.getFeeds()), } this.updateCallListeners(null, this.props.call); @@ -203,14 +203,7 @@ export default class CallView extends React.Component { }; private onFeedsChanged = (newFeeds: Array) => { - // Sort the feeds so that screensharing and remote feeds have priority - const sortedFeeds = [...newFeeds].sort((a, b) => { - if (b.purpose === SDPStreamMetadataPurpose.Screenshare && !b.isLocal()) return 1; - if (a.isLocal() && !b.isLocal()) return 1; - return -1; - }); - - this.setState({feeds: sortedFeeds}); + this.setState({feeds: this.sortFeeds(newFeeds)}); }; private onCallLocalHoldUnhold = () => { @@ -253,6 +246,15 @@ export default class CallView extends React.Component { this.showControls(); } + private sortFeeds(feeds: Array) { + // Sort the feeds so that screensharing and remote feeds have priority + return [...feeds].sort((a, b) => { + if (b.purpose === SDPStreamMetadataPurpose.Screenshare && !b.isLocal()) return 1; + if (a.isLocal() && !b.isLocal()) return 1; + return -1; + }); + } + private showControls() { if (this.state.showMoreMenu || this.state.showDialpad) return;