mirror of https://github.com/jitsi/jitsi-meet
parent
38b9819b68
commit
80685395ed
@ -0,0 +1,24 @@ |
||||
import { Symbol } from '../base/react'; |
||||
|
||||
/** |
||||
* The type of Redux action which begins a (user) request to lock a specific |
||||
* JitsiConference. |
||||
* |
||||
* { |
||||
* type: BEGIN_ROOM_LOCK_REQUEST, |
||||
* conference: JitsiConference |
||||
* } |
||||
*/ |
||||
export const BEGIN_ROOM_LOCK_REQUEST = Symbol('BEGIN_ROOM_LOCK_REQUEST'); |
||||
|
||||
/** |
||||
* The type of Redux action which end a (user) request to lock a specific |
||||
* JitsiConference. |
||||
* |
||||
* { |
||||
* type: END_ROOM_LOCK_REQUEST, |
||||
* conference: JitsiConference, |
||||
* password: string |
||||
* } |
||||
*/ |
||||
export const END_ROOM_LOCK_REQUEST = Symbol('END_ROOM_LOCK_REQUEST'); |
@ -0,0 +1,56 @@ |
||||
import { setPassword } from '../base/conference'; |
||||
|
||||
import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes'; |
||||
import './reducer'; |
||||
|
||||
/** |
||||
* 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} |
||||
*/ |
||||
export function beginRoomLockRequest(conference) { |
||||
return (dispatch, getState) => { |
||||
if (typeof conference === 'undefined') { |
||||
const state = getState(); |
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
conference = state['features/base/conference'].conference; |
||||
} |
||||
|
||||
if (conference) { |
||||
dispatch({ |
||||
type: BEGIN_ROOM_LOCK_REQUEST, |
||||
conference |
||||
}); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 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} |
||||
*/ |
||||
export function endRoomLockRequest(conference, password) { |
||||
return dispatch => { |
||||
const setPassword_ |
||||
= password |
||||
? dispatch(setPassword(conference, conference.lock, password)) |
||||
: Promise.resolve(); |
||||
const endRoomLockRequest_ = () => { |
||||
dispatch({ |
||||
type: END_ROOM_LOCK_REQUEST, |
||||
conference, |
||||
password |
||||
}); |
||||
}; |
||||
|
||||
setPassword_.then(endRoomLockRequest_, endRoomLockRequest_); |
||||
}; |
||||
} |
@ -0,0 +1,83 @@ |
||||
import React, { Component } from 'react'; |
||||
import Prompt from 'react-native-prompt'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { endRoomLockRequest } from '../actions'; |
||||
|
||||
/** |
||||
* Implements a React Component which prompts the user for a password to lock a |
||||
* conference/room. |
||||
*/ |
||||
class RoomLockPrompt extends Component { |
||||
/** |
||||
* RoomLockPrompt component's property types. |
||||
* |
||||
* @static |
||||
*/ |
||||
static propTypes = { |
||||
/** |
||||
* The JitsiConference which requires a password. |
||||
* |
||||
* @type {JitsiConference} |
||||
*/ |
||||
conference: React.PropTypes.object, |
||||
dispatch: React.PropTypes.func |
||||
} |
||||
|
||||
/** |
||||
* Initializes a new RoomLockPrompt instance. |
||||
* |
||||
* @param {Object} props - The read-only properties with which the new |
||||
* instance is to be initialized. |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
// Bind event handlers so they are only bound once for every instance.
|
||||
this._onCancel = this._onCancel.bind(this); |
||||
this._onSubmit = this._onSubmit.bind(this); |
||||
} |
||||
|
||||
/** |
||||
* Implements React's {@link Component#render()}. |
||||
* |
||||
* @inheritdoc |
||||
* @returns {ReactElement} |
||||
*/ |
||||
render() { |
||||
return ( |
||||
<Prompt |
||||
onCancel = { this._onCancel } |
||||
onSubmit = { this._onSubmit } |
||||
placeholder = 'Password' |
||||
title = 'Lock / Unlock room' |
||||
visible = { true } /> |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Notifies this prompt that it has been dismissed by cancel. |
||||
* |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_onCancel() { |
||||
// An undefined password is understood to cancel the request to lock the
|
||||
// conference/room.
|
||||
this._onSubmit(undefined); |
||||
} |
||||
|
||||
/** |
||||
* Notifies this prompt that it has been dismissed by submitting a specific |
||||
* value. |
||||
* |
||||
* @param {string} value - The submitted value. |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_onSubmit(value) { |
||||
this.props.dispatch(endRoomLockRequest(this.props.conference, value)); |
||||
} |
||||
} |
||||
|
||||
export default connect()(RoomLockPrompt); |
@ -0,0 +1 @@ |
||||
export { default as RoomLockPrompt } from './RoomLockPrompt'; |
@ -0,0 +1,2 @@ |
||||
export * from './actions'; |
||||
export * from './components'; |
@ -0,0 +1,33 @@ |
||||
import { |
||||
CONFERENCE_FAILED, |
||||
CONFERENCE_JOINED, |
||||
CONFERENCE_LEFT |
||||
} from '../base/conference'; |
||||
import { ReducerRegistry, setStateProperty } from '../base/redux'; |
||||
|
||||
import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes'; |
||||
|
||||
ReducerRegistry.register('features/room-lock', (state = {}, action) => { |
||||
switch (action.type) { |
||||
case BEGIN_ROOM_LOCK_REQUEST: |
||||
return setStateProperty(state, 'requested', action.conference); |
||||
|
||||
case CONFERENCE_FAILED: |
||||
case CONFERENCE_LEFT: |
||||
case END_ROOM_LOCK_REQUEST: { |
||||
if (state.requested === action.conference) { |
||||
return setStateProperty(state, 'requested', undefined); |
||||
} |
||||
break; |
||||
} |
||||
|
||||
case CONFERENCE_JOINED: { |
||||
if (state.requested !== action.conference) { |
||||
return setStateProperty(state, 'requested', undefined); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return state; |
||||
}); |
Loading…
Reference in new issue