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

View File

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