ref(recording-label): derive when the label state is no longer stale

This commit is contained in:
Leonard Kim 2018-11-05 14:14:44 -08:00 committed by Leonard Kim
parent f13cfe70f3
commit d4e18e78fa
1 changed files with 15 additions and 8 deletions

View File

@ -54,6 +54,18 @@ const STALE_TIMEOUT = 10 * 1000;
*/
export default class AbstractRecordingLabel
extends Component<Props, State> {
/**
* 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
});
}
}
}
/**