From d4e18e78faa1540a59d20cd87f828c2afe4b11e4 Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Mon, 5 Nov 2018 14:14:44 -0800 Subject: [PATCH] ref(recording-label): derive when the label state is no longer stale --- .../components/AbstractRecordingLabel.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/react/features/recording/components/AbstractRecordingLabel.js b/react/features/recording/components/AbstractRecordingLabel.js index 78fcb5c34..227e58cf7 100644 --- a/react/features/recording/components/AbstractRecordingLabel.js +++ b/react/features/recording/components/AbstractRecordingLabel.js @@ -54,6 +54,18 @@ const STALE_TIMEOUT = 10 * 1000; */ export default class AbstractRecordingLabel extends Component { + /** + * Implements {@code Component#getDerivedStateFromProps}. + * + * @inheritdoc + */ + static getDerivedStateFromProps(props: Props, prevState: State) { + return { + staleLabel: props._status !== JitsiRecordingConstants.status.OFF + && prevState.staleLabel ? false : prevState.staleLabel + }; + } + /** * Initializes a new {@code AbstractRecordingLabel} component. * @@ -70,12 +82,12 @@ export default class AbstractRecordingLabel } /** - * Implements {@code Component#componentWillReceiveProps}. + * Implements {@code Component#componentDidUpdate}. * * @inheritdoc */ - componentWillReceiveProps(newProps: Props) { - this._updateStaleStatus(this.props, newProps); + componentDidUpdate(prevProps: Props) { + this._updateStaleStatus(prevProps, this.props); } /** @@ -137,13 +149,8 @@ export default class AbstractRecordingLabel } }, STALE_TIMEOUT); } - } else if (this.state.staleLabel) { - this.setState({ - staleLabel: false - }); } } - } /**