Select random peer if no peer has spoken yet

master
Torjus 2018-08-02 13:01:35 +02:00
parent c249472423
commit cf0e313d58
3 changed files with 64 additions and 2 deletions

View File

@ -21,9 +21,27 @@ class Filmstrip extends Component
};
// Find the name of the peer which is currently speaking. This is either
// the latest active speaker, or the manually selected peer.
// the latest active speaker, or the manually selected peer, or, if no
// person has spoken yet, the first peer in the list of peers.
getActivePeerName = () =>
this.props.selectedPeerName || this.state.lastSpeaker;
{
if (this.props.selectedPeerName)
{
return this.props.selectedPeerName;
}
if (this.state.lastSpeaker)
{
return this.state.lastSpeaker;
}
const peerNames = Object.keys(this.props.peers);
if (peerNames.length > 0)
{
return peerNames[0];
}
};
isSharingCamera = (peerName) => this.props.peers[peerName] &&
this.props.peers[peerName].consumers.some((consumer) =>

View File

@ -0,0 +1,38 @@
import React from 'react';
import { connect } from 'react-redux';
import { Me } from '../appPropTypes';
const ListMe = ({ me }) =>
{
const picture = me.picture || 'resources/images/avatar-empty.jpeg';
return (
<li className='list-item me'>
<div data-component='ListPeer'>
<img className='avatar' src={picture} />
<div className='peer-info'>
{me.displayName}
</div>
<div className='indicators'>
{me.raisedHand && (
<div className='icon raise-hand on' />
)}
</div>
</div>
</li>
);
};
ListMe.propTypes = {
me : Me.isRequired
};
const mapStateToProps = (state) => ({
me : state.me
});
export default connect(
mapStateToProps
)(ListMe);

View File

@ -12,6 +12,10 @@
overflow: hidden;
cursor: pointer;
&.me {
cursor: auto;
}
&.selected {
border-bottom-color: #377EFF;
}
@ -21,6 +25,8 @@
[data-component='ListPeer'] {
display: flex;
align-items: center;
> .indicators {
left: 0;
top: 0;