From 1e3e71c2ffccecac38b50839a8bb454b3c63392c Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Sun, 28 Oct 2018 19:10:47 -0700 Subject: [PATCH] ref(speaker-stats): begin polling for stats after mount --- .../speaker-stats/components/SpeakerStats.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/react/features/speaker-stats/components/SpeakerStats.js b/react/features/speaker-stats/components/SpeakerStats.js index c191f56ce..56f565929 100644 --- a/react/features/speaker-stats/components/SpeakerStats.js +++ b/react/features/speaker-stats/components/SpeakerStats.js @@ -12,7 +12,7 @@ import SpeakerStatsLabels from './SpeakerStatsLabels'; declare var interfaceConfig: Object; /** - * The type of the React {@code Component} props of {@link SpeakerStats} + * The type of the React {@code Component} props of {@link SpeakerStats}. */ type Props = { @@ -33,7 +33,7 @@ type Props = { }; /** - * The type of the React {@code Component} state of {@link SpeakerStats} + * The type of the React {@code Component} state of {@link SpeakerStats}. */ type State = { @@ -49,10 +49,6 @@ type State = { * @extends Component */ class SpeakerStats extends Component { - state = { - stats: {} - }; - _updateInterval: IntervalID; /** @@ -64,19 +60,20 @@ class SpeakerStats extends Component { constructor(props) { super(props); + this.state = { + stats: this.props.conference.getSpeakerStats() + }; + // Bind event handlers so they are only bound once per instance. this._updateStats = this._updateStats.bind(this); } /** - * Immediately request for updated speaker stats and begin - * polling for speaker stats updates. + * Begin polling for speaker stats updates. * * @inheritdoc - * @returns {void} */ - componentWillMount() { - this._updateStats(); + componentDidMount() { this._updateInterval = setInterval(this._updateStats, 1000); }