Improve and fix sorting

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-05-08 18:50:13 +02:00
parent 430808ae2e
commit 69b0425c10
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
1 changed files with 9 additions and 8 deletions

View File

@ -203,7 +203,14 @@ export default class CallView extends React.Component<IProps, IState> {
}; };
private onFeedsChanged = (newFeeds: Array<CallFeed>) => { private onFeedsChanged = (newFeeds: Array<CallFeed>) => {
this.setState({feeds: newFeeds}); // 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});
}; };
private onCallLocalHoldUnhold = () => { private onCallLocalHoldUnhold = () => {
@ -396,13 +403,7 @@ export default class CallView extends React.Component<IProps, IState> {
} }
private renderFeeds(feeds: Array<CallFeed>, offset = 0) { private renderFeeds(feeds: Array<CallFeed>, offset = 0) {
const sortedFeeds = [...feeds].sort((a, b) => { return feeds.map((feed, i) => {
if (b.purpose === SDPStreamMetadataPurpose.Screenshare && !b.isLocal()) return 1;
if (a.isLocal() && !b.isLocal()) return 1;
return 0;
});
return sortedFeeds.map((feed, i) => {
i += offset; i += offset;
// TODO: Later the CallView should probably be reworked to support // TODO: Later the CallView should probably be reworked to support
// any number of feeds but now we can't render more than 4 feeds // any number of feeds but now we can't render more than 4 feeds