Always sort feeds

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-05-10 13:21:02 +02:00
parent 228b2ccf2d
commit 90f4ad7a83
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -128,7 +128,7 @@ export default class CallView extends React.Component<IProps, IState> {
controlsVisible: true, controlsVisible: true,
showMoreMenu: false, showMoreMenu: false,
showDialpad: false, showDialpad: false,
feeds: this.props.call.getFeeds(), feeds: this.sortFeeds(this.props.call.getFeeds()),
} }
this.updateCallListeners(null, this.props.call); this.updateCallListeners(null, this.props.call);
@ -203,14 +203,7 @@ export default class CallView extends React.Component<IProps, IState> {
}; };
private onFeedsChanged = (newFeeds: Array<CallFeed>) => { private onFeedsChanged = (newFeeds: Array<CallFeed>) => {
// Sort the feeds so that screensharing and remote feeds have priority this.setState({feeds: this.sortFeeds(newFeeds)});
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});
}; };
private onCallLocalHoldUnhold = () => { private onCallLocalHoldUnhold = () => {
@ -253,6 +246,15 @@ export default class CallView extends React.Component<IProps, IState> {
this.showControls(); this.showControls();
} }
private sortFeeds(feeds: Array<CallFeed>) {
// 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() { private showControls() {
if (this.state.showMoreMenu || this.state.showDialpad) return; if (this.state.showMoreMenu || this.state.showDialpad) return;