2017-10-02 23:08:07 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-08-30 23:17:55 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
2017-09-08 20:52:07 +00:00
|
|
|
import { getAvatarURL, getParticipants } from '../../base/participants';
|
2017-08-30 23:17:55 +00:00
|
|
|
|
|
|
|
import ContactListItem from './ContactListItem';
|
|
|
|
|
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
|
|
|
/**
|
2017-09-29 18:29:44 +00:00
|
|
|
* React component for showing a list of current conference participants.
|
2017-08-30 23:17:55 +00:00
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class ContactListPanel extends Component {
|
|
|
|
/**
|
|
|
|
* Default values for {@code ContactListPanel} component's properties.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* The participants to show in the contact list.
|
|
|
|
*/
|
|
|
|
_participants: PropTypes.array,
|
|
|
|
|
|
|
|
/**
|
2017-09-29 18:29:44 +00:00
|
|
|
* Whether or not participant avatars should be displayed.
|
2017-08-30 23:17:55 +00:00
|
|
|
*/
|
2017-09-29 18:29:44 +00:00
|
|
|
_showAvatars: PropTypes.bool,
|
2017-08-30 23:17:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: PropTypes.func
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2017-09-29 18:29:44 +00:00
|
|
|
const { _participants, t } = this.props;
|
2017-08-30 23:17:55 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = 'contact-list-panel'>
|
|
|
|
<div className = 'title'>
|
2017-09-29 18:29:44 +00:00
|
|
|
{ t('contactlist', { count: _participants.length }) }
|
2017-08-30 23:17:55 +00:00
|
|
|
</div>
|
|
|
|
<ul id = 'contacts'>
|
|
|
|
{ this._renderContacts() }
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders React Elements for displaying information about each participant
|
|
|
|
* in the contact list.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement[]}
|
|
|
|
*/
|
|
|
|
_renderContacts() {
|
2017-10-17 19:07:20 +00:00
|
|
|
const { t } = this.props;
|
|
|
|
const meString = t('me');
|
|
|
|
|
2017-09-08 20:52:07 +00:00
|
|
|
return this.props._participants.map(participant => {
|
2017-10-17 19:07:20 +00:00
|
|
|
const { id, local, name } = participant;
|
|
|
|
let displayName;
|
|
|
|
|
|
|
|
// FIXME this duplicates the logic from SpeakerStats.js, but
|
|
|
|
// currently it seems that the
|
|
|
|
// interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME is freely used in
|
|
|
|
// multiple other places. A proper fix should take care of all
|
|
|
|
// usages. Also conference.js has getParticipantDisplayName which
|
|
|
|
// generates HTML span making things even harder to be cleaned up
|
|
|
|
// properly.
|
|
|
|
if (local) {
|
|
|
|
displayName
|
|
|
|
= name ? `${name} (${meString})` : meString;
|
|
|
|
} else {
|
|
|
|
displayName
|
|
|
|
= name ? name : interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
|
|
|
}
|
2017-09-08 20:52:07 +00:00
|
|
|
|
|
|
|
return (
|
2017-08-30 23:17:55 +00:00
|
|
|
<ContactListItem
|
2017-09-29 18:29:44 +00:00
|
|
|
avatarURI = { this.props._showAvatars
|
2017-09-08 20:52:07 +00:00
|
|
|
? getAvatarURL(participant) : null }
|
2017-08-30 23:17:55 +00:00
|
|
|
id = { id }
|
|
|
|
key = { id }
|
2017-10-17 19:07:20 +00:00
|
|
|
name = { displayName } />
|
2017-09-08 20:52:07 +00:00
|
|
|
);
|
|
|
|
});
|
2017-08-30 23:17:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code ContactListPanel}'s
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _locked: boolean,
|
|
|
|
* _participants: Array
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
2017-09-29 18:29:44 +00:00
|
|
|
_participants: getParticipants(state),
|
|
|
|
_showAvatars: interfaceConfig.SHOW_CONTACTLIST_AVATARS
|
2017-08-30 23:17:55 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(ContactListPanel));
|