ref(conference): remove deprecated lifecycle methods

This commit is contained in:
Leonard Kim 2018-12-06 18:15:03 -08:00 committed by Saúl Ibarra Corretgé
parent 545ad0e1a6
commit 3ebad112a2
1 changed files with 18 additions and 28 deletions

View File

@ -168,6 +168,8 @@ class Conference extends Component<Props> {
* @returns {void} * @returns {void}
*/ */
componentDidMount() { componentDidMount() {
this.props._onConnect();
// Set handling any hardware button presses for back navigation up. // Set handling any hardware button presses for back navigation up.
const backHandler = BackHandler || BackAndroid; const backHandler = BackHandler || BackAndroid;
@ -186,39 +188,23 @@ class Conference extends Component<Props> {
} }
/** /**
* Implements {@link Component#componentWillMount()}. Invoked immediately * Implements React's {@link Component#componentDidUpdate()}.
* before mounting occurs. Connects the conference described by the redux
* store/state.
* *
* @inheritdoc * @inheritdoc
* @returns {void}
*/ */
componentWillMount() { componentDidUpdate(pevProps: Props) {
this.props._onConnect();
}
/**
* Notifies this mounted React {@code Component} that it will receive new
* props. Check if we need to show / hide the toolbox based on the
* participant count.
*
* @inheritdoc
* @param {Props} nextProps - The read-only React {@code Component} props
* that this instance will receive.
* @returns {void}
*/
componentWillReceiveProps(nextProps: Props) {
const { const {
_locationURL: oldLocationURL, _locationURL: oldLocationURL,
_participantCount: oldParticipantCount, _participantCount: oldParticipantCount,
_room: oldRoom, _room: oldRoom
_setToolboxVisible } = pevProps;
} = this.props;
const { const {
_locationURL: newLocationURL, _locationURL: newLocationURL,
_participantCount: newParticipantCount, _participantCount: newParticipantCount,
_room: newRoom _room: newRoom,
} = nextProps; _setToolboxVisible,
_toolboxVisible
} = this.props;
// If the location URL changes we need to reconnect. // If the location URL changes we need to reconnect.
oldLocationURL !== newLocationURL && this.props._onDisconnect(); oldLocationURL !== newLocationURL && this.props._onDisconnect();
@ -226,10 +212,14 @@ class Conference extends Component<Props> {
// Start the connection process when there is a (valid) room. // Start the connection process when there is a (valid) room.
oldRoom !== newRoom && newRoom && this.props._onConnect(); oldRoom !== newRoom && newRoom && this.props._onConnect();
if (oldParticipantCount === 1) { if (oldParticipantCount === 1
newParticipantCount > 1 && _setToolboxVisible(false); && newParticipantCount > 1
} else if (oldParticipantCount > 1) { && _toolboxVisible) {
newParticipantCount === 1 && _setToolboxVisible(true); _setToolboxVisible(false);
} else if (oldParticipantCount > 1
&& newParticipantCount === 1
&& !_toolboxVisible) {
_setToolboxVisible(true);
} }
} }