jiti-meet/react/features/room-lock/actions.js

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-10-04 22:36:09 +00:00
// @flow
2016-12-13 09:14:04 +00:00
import { setPassword } from '../base/conference';
import { hideDialog, openDialog } from '../base/dialog';
import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
2016-12-13 09:14:04 +00:00
/**
* Begins a (user) request to lock a specific conference/room.
*
* @param {JitsiConference|undefined} conference - The JitsiConference to lock
* if specified or undefined if the current JitsiConference is to be locked.
* @returns {Function}
*/
2017-10-04 22:36:09 +00:00
export function beginRoomLockRequest(conference: ?Object) {
return (dispatch: Function, getState: Function) => {
2016-12-13 09:14:04 +00:00
if (typeof conference === 'undefined') {
// eslint-disable-next-line no-param-reassign
2017-10-04 22:36:09 +00:00
conference = getState()['features/base/conference'].conference;
2016-12-13 09:14:04 +00:00
}
if (conference) {
dispatch(openDialog(RoomLockPrompt, { conference }));
2016-12-13 09:14:04 +00:00
}
};
}
/**
* Ends a (user) request to lock a specific conference/room.
*
* @param {JitsiConference} conference - The JitsiConference to lock.
* @param {string|undefined} password - The password with which the specified
* conference is to be locked or undefined to cancel the (user) request to lock
* the specified conference.
* @returns {Function}
*/
2017-10-04 22:36:09 +00:00
export function endRoomLockRequest(
conference: { lock: Function },
password: ?string) {
return (dispatch: Function) => {
2016-12-13 09:14:04 +00:00
const setPassword_
= password
? dispatch(setPassword(conference, conference.lock, password))
: Promise.resolve();
2017-10-04 22:36:09 +00:00
const endRoomLockRequest_ = () => dispatch(hideDialog(RoomLockPrompt));
2016-12-13 09:14:04 +00:00
setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
};
}
/**
* Begins a request to enter password for a specific conference/room.
*
* @param {JitsiConference} conference - The JitsiConference
* requesting password.
* @protected
* @returns {{
* type: OPEN_DIALOG,
* component: Component,
* props: PropTypes
* }}
*/
2017-10-04 22:36:09 +00:00
export function _openPasswordRequiredPrompt(conference: Object) {
return openDialog(PasswordRequiredPrompt, { conference });
}