webRTC video stats: fetch stats on VideoListItem

This commit is contained in:
Augusto Bennemann 2018-06-04 13:53:41 -03:00
parent 2eaa457442
commit 6f16948824
2 changed files with 9 additions and 14 deletions

View File

@ -38,6 +38,13 @@ class VideoListItem extends Component {
} }
toggleStats() { toggleStats() {
const { getStats, stopGettingStats } = this.props;
if (this.state.showStats) {
stopGettingStats();
} else {
getStats(this.videoTag, this.setStats);
}
this.setState({showStats: !this.state.showStats}); this.setState({showStats: !this.state.showStats});
} }
@ -70,7 +77,7 @@ class VideoListItem extends Component {
render() { render() {
const { showStats, stats } = this.state; const { showStats, stats } = this.state;
const { user, getStats, stopGettingStats } = this.props; const { user } = this.props;
const availableActions = this.getAvailableActions(); const availableActions = this.getAvailableActions();
@ -102,7 +109,7 @@ class VideoListItem extends Component {
{ user.isMuted ? <Icon className={styles.muted} iconName="unmute_filled" /> : null } { user.isMuted ? <Icon className={styles.muted} iconName="unmute_filled" /> : null }
{ user.isListenOnly ? <Icon className={styles.voice} iconName="listen" /> : null } { user.isListenOnly ? <Icon className={styles.voice} iconName="listen" /> : null }
</div> </div>
{ showStats ? <VideoListItemStats toggleStats={this.toggleStats} getStats={() => getStats(this.videoTag, this.setStats)} stats={stats} stopGettingStats={stopGettingStats} /> : null } { showStats ? <VideoListItemStats toggleStats={this.toggleStats} stats={stats} /> : null }
</div> </div>
); );
} }

View File

@ -8,9 +8,7 @@ import { styles } from '../../styles';
const propTypes = { const propTypes = {
toggleStats: PropTypes.func.isRequired, toggleStats: PropTypes.func.isRequired,
getStats: PropTypes.func.isRequired,
stats: PropTypes.object.isRequired, stats: PropTypes.object.isRequired,
stopGettingStats: PropTypes.func.isRequired,
}; };
const intlMessages = defineMessages({ const intlMessages = defineMessages({
@ -61,16 +59,6 @@ class VideoListItemStats extends Component {
} }
componentDidMount(){
const { getStats } = this.props;
getStats();
}
componentWillUnmount() {
const { stopGettingStats } = this.props;
stopGettingStats();
}
render() { render() {
const { intl, toggleStats, stats } = this.props; const { intl, toggleStats, stats } = this.props;