Show peer icon when no video

This commit is contained in:
Jerko Steiner 2017-06-18 08:35:20 -04:00
parent cad9b70d50
commit 8a8c7b570f
4 changed files with 24 additions and 10 deletions

View File

@ -47,6 +47,9 @@ describe('App', () => {
state.streams = state.streams.merge({ state.streams = state.streams.merge({
test: 'blob://' test: 'blob://'
}) })
state.peers = {
test: {}
}
state.notifications = state.notifications.merge({ state.notifications = state.notifications.merge({
'notification1': { 'notification1': {
id: 'notification1', id: 'notification1',
@ -83,7 +86,7 @@ describe('App', () => {
TestUtils.Simulate.click(video) TestUtils.Simulate.click(video)
expect(store.getActions()).toEqual([{ expect(store.getActions()).toEqual([{
type: constants.ACTIVE_TOGGLE, type: constants.ACTIVE_TOGGLE,
payload: { userId: 'test' } payload: { userId: constants.ME }
}]) }])
}) })
}) })

View File

@ -1,4 +1,5 @@
import Alerts, { AlertPropType } from './Alerts.js' import Alerts, { AlertPropType } from './Alerts.js'
import * as constants from '../constants.js'
import Input from './Input.js' import Input from './Input.js'
import Notifications, { NotificationPropTypes } from './Notifications.js' import Notifications, { NotificationPropTypes } from './Notifications.js'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
@ -8,15 +9,16 @@ import _ from 'underscore'
export default class App extends React.Component { export default class App extends React.Component {
static propTypes = { static propTypes = {
dismissAlert: PropTypes.func.isRequired,
streams: PropTypes.objectOf(PropTypes.string).isRequired,
alerts: PropTypes.arrayOf(AlertPropType).isRequired,
toggleActive: PropTypes.func.isRequired,
active: PropTypes.string, active: PropTypes.string,
alerts: PropTypes.arrayOf(AlertPropType).isRequired,
dismissAlert: PropTypes.func.isRequired,
init: PropTypes.func.isRequired, init: PropTypes.func.isRequired,
notify: PropTypes.func.isRequired,
notifications: PropTypes.objectOf(NotificationPropTypes).isRequired, notifications: PropTypes.objectOf(NotificationPropTypes).isRequired,
sendMessage: PropTypes.func.isRequired notify: PropTypes.func.isRequired,
peers: PropTypes.object.isRequired,
sendMessage: PropTypes.func.isRequired,
streams: PropTypes.objectOf(PropTypes.string).isRequired,
toggleActive: PropTypes.func.isRequired
} }
componentDidMount () { componentDidMount () {
const { init } = this.props const { init } = this.props
@ -29,6 +31,7 @@ export default class App extends React.Component {
dismissAlert, dismissAlert,
notifications, notifications,
notify, notify,
peers,
sendMessage, sendMessage,
toggleActive, toggleActive,
streams streams
@ -39,12 +42,19 @@ export default class App extends React.Component {
<Notifications notifications={notifications} /> <Notifications notifications={notifications} />
<Input notify={notify} sendMessage={sendMessage} /> <Input notify={notify} sendMessage={sendMessage} />
<div className="videos"> <div className="videos">
{_.map(streams, (stream, userId) => ( <Video
active={active === constants.ME}
onClick={toggleActive}
stream={streams[constants.ME]}
userId={constants.ME}
/>
{_.map(peers, (_, userId) => (
<Video <Video
active={userId === active} active={userId === active}
key={userId} key={userId}
onClick={toggleActive} onClick={toggleActive}
stream={stream} stream={streams[userId]}
userId={userId} userId={userId}
/> />
))} ))}

View File

@ -7,7 +7,7 @@ export default class Video extends React.Component {
static propTypes = { static propTypes = {
onClick: PropTypes.func, onClick: PropTypes.func,
active: PropTypes.bool.isRequired, active: PropTypes.bool.isRequired,
stream: PropTypes.string.isRequired, stream: PropTypes.string,
userId: PropTypes.string.isRequired userId: PropTypes.string.isRequired
} }
handleClick = e => { handleClick = e => {

View File

@ -9,6 +9,7 @@ import { connect } from 'react-redux'
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
streams: state.streams, streams: state.streams,
peers: state.peers,
alerts: state.alerts, alerts: state.alerts,
notifications: state.notifications, notifications: state.notifications,
active: state.active active: state.active