import React, { Component } from 'react'; import { connect } from 'react-redux'; import { ScrollView } from 'react-native'; import { Container } from '../../base/react'; import Thumbnail from './Thumbnail'; import { styles } from './_'; /** * React component for film strip. * * @extends Component */ class FilmStrip extends Component { /** * FilmStrip component's property types. * * @static */ static propTypes = { /** * The participants in the conference. * * @private * @type {Participant[]} */ _participants: React.PropTypes.array, visible: React.PropTypes.bool.isRequired } /** * Implements React's {@link Component#render()}. * * @inheritdoc */ render() { return ( { this._sort(this.props._participants) .map(p => ) } ); } /** * Sorts a specific array of Participants in display order. * * @param {Participant[]} participants - The array of Participants * to sort in display order. * @private * @returns {Participant[]} A new array containing the elements of the * specified participants array sorted in display order. */ _sort(participants) { // XXX Array.prototype.sort() is not appropriate because (1) it operates // in place and (2) it is not necessarily stable. const sortedParticipants = []; // Group the remote participants so that the local participant does not // appear in between remote participants. Have the remote participants // from right to left with the newest added/joined to the leftmost side. for (let i = participants.length - 1; i >= 0; --i) { const p = participants[i]; p.local || sortedParticipants.push(p); } // Have the local participant at the rightmost side. for (let i = participants.length - 1; i >= 0; --i) { const p = participants[i]; p.local && sortedParticipants.push(p); } return sortedParticipants; } } /** * Function that maps parts of Redux state tree into component props. * * @param {Object} state - Redux state. * @private * @returns {{ * _participants: Participant[], * }} */ function _mapStateToProps(state) { return { /** * The participants in the conference. * * @private * @type {Participant[]} */ _participants: state['features/base/participants'] }; } export default connect(_mapStateToProps)(FilmStrip);