[RN] Add unlock room function to mobile

This commit is contained in:
Zoltan Bettenbuk 2018-05-17 17:47:05 +02:00 committed by Любомир Маринов
parent b57dad576a
commit 192f1d44f5
4 changed files with 36 additions and 8 deletions

View File

@ -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",

View File

@ -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<Function>, getState: Function) => {
const { conference } = getState()['features/base/conference'];
return dispatch(setPassword(
conference,
conference.lock,
''
));
};
}

View File

@ -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<Props, *> {
* @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<Props, *> {
* @returns {boolean}
*/
_isDisabled() {
return !this.props._conference;
return !this.props._localParticipantModerator;
}
/**
@ -76,14 +84,16 @@ class RoomLockButton extends AbstractButton<Props, *> {
* @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)
};
}

View File

@ -65,7 +65,7 @@ class RoomLockPrompt extends Component<*> {
onCancel = { this._onCancel }
onSubmit = { this._onSubmit }
textInputProps = { _TEXT_INPUT_PROPS }
titleKey = 'toolbar.lock' />
titleKey = 'dialog.lockRoom' />
);
}