From 192f1d44f5516499ed8384ac8b68187f0afdd62b Mon Sep 17 00:00:00 2001 From: Zoltan Bettenbuk Date: Thu, 17 May 2018 17:47:05 +0200 Subject: [PATCH] [RN] Add unlock room function to mobile --- lang/main.json | 1 + react/features/room-lock/actions.js | 17 +++++++++++++ .../room-lock/components/RoomLockButton.js | 24 +++++++++++++------ .../components/RoomLockPrompt.native.js | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lang/main.json b/lang/main.json index 4803ab223..b389d37b8 100644 --- a/lang/main.json +++ b/lang/main.json @@ -230,6 +230,7 @@ "rejoinNow": "Rejoin now", "maxUsersLimitReachedTitle": "Maximum members limit reached", "maxUsersLimitReached": "The limit for maximum number of members has been reached. The conference is full. Please contact the meeting owner or try again later!", + "lockRoom": "Lock room", "lockTitle": "Lock failed", "lockMessage": "Failed to lock the conference.", "warning": "Warning", diff --git a/react/features/room-lock/actions.js b/react/features/room-lock/actions.js index a331d5d23..f6a3a5469 100644 --- a/react/features/room-lock/actions.js +++ b/react/features/room-lock/actions.js @@ -98,3 +98,20 @@ export function endRoomLockRequest( export function _openPasswordRequiredPrompt(conference: Object) { return openDialog(PasswordRequiredPrompt, { conference }); } + +/** + * Unlocks the current jitsi conference. + * + * @returns {Function} + */ +export function unlockRoom() { + return (dispatch: Dispatch, getState: Function) => { + const { conference } = getState()['features/base/conference']; + + return dispatch(setPassword( + conference, + conference.lock, + '' + )); + }; +} diff --git a/react/features/room-lock/components/RoomLockButton.js b/react/features/room-lock/components/RoomLockButton.js index 3b6aad9f8..09b9ab788 100644 --- a/react/features/room-lock/components/RoomLockButton.js +++ b/react/features/room-lock/components/RoomLockButton.js @@ -3,17 +3,19 @@ import { connect } from 'react-redux'; import { translate } from '../../base/i18n'; +import { isLocalParticipantModerator } from '../../base/participants'; import { AbstractButton } from '../../base/toolbox'; import type { AbstractButtonProps } from '../../base/toolbox'; -import { beginRoomLockRequest } from '../actions'; +import { beginRoomLockRequest, unlockRoom } from '../actions'; type Props = AbstractButtonProps & { /** - * The current conference. + * Whether the current local participant is a moderator, therefore is + * allowed to lock or unlock the conference. */ - _conference: Object, + _localParticipantModerator: boolean, /** * Whether the current conference is locked or not. @@ -43,7 +45,13 @@ class RoomLockButton extends AbstractButton { * @returns {void} */ _handleClick() { - this.props.dispatch(beginRoomLockRequest()); + const { dispatch, _locked } = this.props; + + if (_locked) { + dispatch(unlockRoom()); + } else { + dispatch(beginRoomLockRequest()); + } } /** @@ -54,7 +62,7 @@ class RoomLockButton extends AbstractButton { * @returns {boolean} */ _isDisabled() { - return !this.props._conference; + return !this.props._localParticipantModerator; } /** @@ -76,14 +84,16 @@ class RoomLockButton extends AbstractButton { * @param {Object} state - The Redux state. * @private * @returns {{ - * _audioOnly: boolean + * _localParticipantModerator: boolean, + * _locked: boolean * }} */ function _mapStateToProps(state): Object { const { conference, locked } = state['features/base/conference']; return { - _conference: conference, + _localParticipantModerator: + Boolean(conference && isLocalParticipantModerator(state)), _locked: Boolean(conference && locked) }; } diff --git a/react/features/room-lock/components/RoomLockPrompt.native.js b/react/features/room-lock/components/RoomLockPrompt.native.js index eeef69940..42bd7d051 100644 --- a/react/features/room-lock/components/RoomLockPrompt.native.js +++ b/react/features/room-lock/components/RoomLockPrompt.native.js @@ -65,7 +65,7 @@ class RoomLockPrompt extends Component<*> { onCancel = { this._onCancel } onSubmit = { this._onSubmit } textInputProps = { _TEXT_INPUT_PROPS } - titleKey = 'toolbar.lock' /> + titleKey = 'dialog.lockRoom' /> ); }