Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Add unlock room function to mobile

Zoltan Bettenbuk192f1d44f551
diff --git a/lang/main.json b/lang/main.json
index 4803ab2234..b389d37b8b 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 a331d5d23c..f6a3a5469b 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<Function>, 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 3b6aad9f8f..09b9ab788b 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<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)
};
}
diff --git a/react/features/room-lock/components/RoomLockPrompt.native.js b/react/features/room-lock/components/RoomLockPrompt.native.js
index eeef69940b..42bd7d0513 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' />
);
}