Comply w/ coding style

@virtuacoplenny, the changes of this commit are not necessarily in
source code that you introduced in
https://github.com/jitsi/jitsi-meet/pull/1499 but I saw violations in
files modified in the PR which I had to read in order to understand the
PR.
This commit is contained in:
Lyubo Marinov 2017-04-18 16:49:52 -05:00
parent 44b81b20e3
commit 55c3f5ddff
16 changed files with 211 additions and 147 deletions

View File

@ -409,12 +409,9 @@ class ConferenceConnector {
break; break;
// not enough rights to create conference // not enough rights to create conference
case ConferenceErrors.AUTHENTICATION_REQUIRED: case ConferenceErrors.AUTHENTICATION_REQUIRED: {
{ // Schedule reconnect to check if someone else created the room.
// schedule reconnect to check if someone else created the room this.reconnectTimeout = setTimeout(() => room.join(), 5000);
this.reconnectTimeout = setTimeout(function () {
room.join();
}, 5000);
const { password } const { password }
= APP.store.getState()['features/base/conference']; = APP.store.getState()['features/base/conference'];
@ -1449,9 +1446,9 @@ export default {
APP.UI.changeDisplayName(id, formattedDisplayName); APP.UI.changeDisplayName(id, formattedDisplayName);
}); });
room.on(ConferenceEvents.LOCK_STATE_CHANGED, (...args) => { room.on(
APP.store.dispatch(lockStateChanged(room, ...args)); ConferenceEvents.LOCK_STATE_CHANGED,
}); (...args) => APP.store.dispatch(lockStateChanged(room, ...args)));
room.on(ConferenceEvents.PARTICIPANT_PROPERTY_CHANGED, room.on(ConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
(participant, name, oldValue, newValue) => { (participant, name, oldValue, newValue) => {

View File

@ -24,18 +24,18 @@
margin-top: 10px; margin-top: 10px;
} }
.password-overview-toggle-edit,
.remove-password-link {
cursor: pointer;
text-decoration: none;
}
.password-overview-status, .password-overview-status,
.remove-password { .remove-password {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.password-overview-toggle-edit,
.remove-password-link {
cursor: pointer;
text-decoration: none;
}
.remove-password { .remove-password {
margin-top: 15px; margin-top: 15px;
} }

View File

@ -24,9 +24,7 @@ class ContactList {
* @returns {Boolean} * @returns {Boolean}
*/ */
isLocked() { isLocked() {
const conference = APP.store.getState()['features/base/conference']; return APP.store.getState()['features/base/conference'].locked;
return conference.locked;
} }
/** /**
@ -36,9 +34,9 @@ class ContactList {
* @param isLocal * @param isLocal
*/ */
addContact(id, isLocal) { addContact(id, isLocal) {
let isExist = this.contacts.some((el) => el.id === id); const exists = this.contacts.some(el => el.id === id);
if (!isExist) { if (!exists) {
let newContact = new Contact({ id, isLocal }); let newContact = new Contact({ id, isLocal });
this.contacts.push(newContact); this.contacts.push(newContact);
APP.UI.emitEvent(UIEvents.CONTACT_ADDED, { id, isLocal }); APP.UI.emitEvent(UIEvents.CONTACT_ADDED, { id, isLocal });

View File

@ -1,5 +1,4 @@
/* global $, APP, interfaceConfig */ /* global $, APP, interfaceConfig */
const logger = require("jitsi-meet-logger").getLogger(__filename);
import { openInviteDialog } from '../../../../react/features/invite'; import { openInviteDialog } from '../../../../react/features/invite';
@ -7,6 +6,8 @@ import Avatar from '../../avatar/Avatar';
import UIEvents from '../../../../service/UI/UIEvents'; import UIEvents from '../../../../service/UI/UIEvents';
import UIUtil from '../../util/UIUtil'; import UIUtil from '../../util/UIUtil';
const logger = require('jitsi-meet-logger').getLogger(__filename);
let numberOfContacts = 0; let numberOfContacts = 0;
const sidePanelsContainerId = 'sideToolbarContainer'; const sidePanelsContainerId = 'sideToolbarContainer';
const htmlStr = ` const htmlStr = `
@ -169,20 +170,28 @@ var ContactListView = {
APP.UI.addListener(UIEvents.USER_AVATAR_CHANGED, changeAvatar); APP.UI.addListener(UIEvents.USER_AVATAR_CHANGED, changeAvatar);
APP.UI.addListener(UIEvents.DISPLAY_NAME_CHANGED, displayNameChange); APP.UI.addListener(UIEvents.DISPLAY_NAME_CHANGED, displayNameChange);
}, },
/** /**
* Updates the view according to the passed in lock state. * Updates the view according to the passed in lock state.
* *
* @param {boolean} isLocked - True if the locked UI state should display. * @param {boolean} locked - True to display the locked UI state or false to
* display the unlocked UI state.
*/ */
setLockDisplay(isLocked) { setLockDisplay(locked) {
const showKey = isLocked ? this.lockKey : this.unlockKey; let hideKey, showKey;
const hideKey = !isLocked ? this.lockKey : this.unlockKey;
const showId = `contactList${showKey}`;
const hideId = `contactList${hideKey}`;
$(`#${showId}`).show(); if (locked) {
$(`#${hideId}`).hide(); hideKey = this.unlockKey;
showKey = this.lockKey;
} else {
hideKey = this.lockKey;
showKey = this.unlockKey;
}
$(`#contactList${hideKey}`).hide();
$(`#contactList${showKey}`).show();
}, },
/** /**
* Indicates if the chat is currently visible. * Indicates if the chat is currently visible.
* *

View File

@ -118,7 +118,7 @@ export const SET_PASSWORD = Symbol('SET_PASSWORD');
/** /**
* The type of Redux action which signals that setting a password on a * The type of Redux action which signals that setting a password on a
* JitsiConference encountered an error and failed. * JitsiConference failed (with an error).
* *
* { * {
* type: SET_PASSWORD_FAILED, * type: SET_PASSWORD_FAILED,

View File

@ -85,6 +85,14 @@ function _conferenceFailed(state, action) {
audioOnlyVideoMuted: undefined, audioOnlyVideoMuted: undefined,
conference: undefined, conference: undefined,
leaving: undefined, leaving: undefined,
/**
* The indicator of how the conference/room is locked. If falsy, the
* conference/room is unlocked; otherwise, it's either
* {@code LOCKED_LOCALLY| or {@code LOCKED_REMOTELY}.
*
* @type {string}
*/
locked: passwordRequired ? LOCKED_REMOTELY : undefined, locked: passwordRequired ? LOCKED_REMOTELY : undefined,
password: undefined, password: undefined,
@ -211,14 +219,14 @@ function _lockStateChanged(state, action) {
return state; return state;
} }
let lockState; let locked;
if (action.locked) { if (action.locked) {
lockState = state.locked || LOCKED_REMOTELY; locked = state.locked || LOCKED_REMOTELY;
} }
return setStateProperties(state, { return setStateProperties(state, {
locked: lockState, locked,
password: action.locked ? state.password : null password: action.locked ? state.password : null
}); });
} }
@ -265,7 +273,7 @@ function _setPassword(state, action) {
const conference = action.conference; const conference = action.conference;
switch (action.method) { switch (action.method) {
case conference.join: { case conference.join:
if (state.passwordRequired === conference) { if (state.passwordRequired === conference) {
return ( return (
setStateProperties(state, { setStateProperties(state, {
@ -280,16 +288,14 @@ function _setPassword(state, action) {
passwordRequired: undefined passwordRequired: undefined
})); }));
} }
break; break;
}
case conference.lock: { case conference.lock:
return setStateProperties(state, { return setStateProperties(state, {
locked: action.password ? LOCKED_LOCALLY : undefined, locked: action.password ? LOCKED_LOCALLY : undefined,
password: action.password password: action.password
}); });
} }
}
return state; return state;
} }

View File

@ -10,9 +10,7 @@ import { InviteDialog } from './components';
* @returns {Function} * @returns {Function}
*/ */
export function openInviteDialog() { export function openInviteDialog() {
return dispatch => { return openDialog(InviteDialog, {
dispatch(openDialog(InviteDialog, {
conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl()) conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl())
})); });
};
} }

View File

@ -5,11 +5,11 @@ import { setPassword } from '../../base/conference';
import { translate } from '../../base/i18n'; import { translate } from '../../base/i18n';
/** /**
* A React Component for locking a JitsiConference with a password. * A React {@code Component} for locking a JitsiConference with a password.
*/ */
class AddPasswordForm extends Component { class AddPasswordForm extends Component {
/** /**
* AddPasswordForm component's property types. * {@code AddPasswordForm}'s property types.
* *
* @static * @static
*/ */
@ -33,7 +33,7 @@ class AddPasswordForm extends Component {
} }
/** /**
* Initializes a new AddPasswordForm instance. * Initializes a new {@code AddPasswordForm} instance.
* *
* @param {Object} props - The read-only properties with which the new * @param {Object} props - The read-only properties with which the new
* instance is to be initialized. * instance is to be initialized.
@ -42,9 +42,17 @@ class AddPasswordForm extends Component {
super(props); super(props);
this.state = { this.state = {
/**
* The current value to display in {@code AddPasswordForm}
* component's input field. The value is also used as the desired
* new password when creating a {@code setPassword} action.
*
* @type {string}
*/
password: '' password: ''
}; };
// Bind event handlers so they are only bound once for every instance.
this._onKeyDown = this._onKeyDown.bind(this); this._onKeyDown = this._onKeyDown.bind(this);
this._onPasswordChange = this._onPasswordChange.bind(this); this._onPasswordChange = this._onPasswordChange.bind(this);
this._onSubmit = this._onSubmit.bind(this); this._onSubmit = this._onSubmit.bind(this);
@ -57,6 +65,8 @@ class AddPasswordForm extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const { t } = this.props;
return ( return (
<div <div
className = 'form-control' className = 'form-control'
@ -68,8 +78,7 @@ class AddPasswordForm extends Component {
id = 'newPasswordInput' id = 'newPasswordInput'
onChange = { this._onPasswordChange } onChange = { this._onPasswordChange }
onKeyDown = { this._onKeyDown } onKeyDown = { this._onKeyDown }
placeholder placeholder = { t('dialog.createPassword') }
= { this.props.t('dialog.createPassword') }
type = 'text' /> type = 'text' />
<button <button
className = 'button-control button-control_light' className = 'button-control button-control_light'
@ -77,7 +86,7 @@ class AddPasswordForm extends Component {
id = 'addPasswordBtn' id = 'addPasswordBtn'
onClick = { this._onSubmit } onClick = { this._onSubmit }
type = 'button'> type = 'button'>
{ this.props.t('dialog.add') } { t('dialog.add') }
</button> </button>
</div> </div>
</div> </div>
@ -122,7 +131,7 @@ class AddPasswordForm extends Component {
return; return;
} }
const conference = this.props.conference; const { conference } = this.props;
this.props.dispatch(setPassword( this.props.dispatch(setPassword(
conference, conference,

View File

@ -13,12 +13,13 @@ import PasswordContainer from './PasswordContainer';
import ShareLinkForm from './ShareLinkForm'; import ShareLinkForm from './ShareLinkForm';
/** /**
* A React Component for displaying other components responsible for copying the * A React {@code Component} for displaying other components responsible for
* current conference url and for setting or removing a conference password. * copying the current conference url and for setting or removing a conference
* password.
*/ */
class InviteDialog extends Component { class InviteDialog extends Component {
/** /**
* InviteDialog component's property types. * {@code InviteDialog} component's property types.
* *
* @static * @static
*/ */
@ -61,19 +62,23 @@ class InviteDialog extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const { _conference } = this.props;
const titleString
= this.props.t(
'invite.inviteTo',
{ conferenceName: _conference.room });
return ( return (
<Dialog <Dialog
cancelDisabled = { true } cancelDisabled = { true }
okTitleKey = 'dialog.done' okTitleKey = 'dialog.done'
titleString = { this.props.t( titleString = { titleString }>
'invite.inviteTo',
{ conferenceName: this.props._conference.room }) } >
<div className = 'invite-dialog'> <div className = 'invite-dialog'>
<ShareLinkForm toCopy = { this.props.conferenceUrl } /> <ShareLinkForm toCopy = { this.props.conferenceUrl } />
<PasswordContainer <PasswordContainer
conference = { this.props._conference.conference } conference = { _conference.conference }
locked = { this.props._conference.locked } locked = { _conference.locked }
password = { this.props._conference.password } password = { _conference.password }
showPasswordEdit = { this.props._isModerator } /> showPasswordEdit = { this.props._isModerator } />
</div> </div>
</Dialog> </Dialog>
@ -82,7 +87,8 @@ class InviteDialog extends Component {
} }
/** /**
* Maps (parts of) the Redux state to the associated InviteDialog's props. * Maps (parts of) the Redux state to the associated {@code InviteDialog}'s
* props.
* *
* @param {Object} state - The Redux state. * @param {Object} state - The Redux state.
* @private * @private

View File

@ -7,7 +7,7 @@ import { translate } from '../../base/i18n';
*/ */
class LockStatePanel extends Component { class LockStatePanel extends Component {
/** /**
* LockStatePanel component's property types. * {@code LockStatePanel}'s property types.
* *
* @static * @static
*/ */
@ -30,15 +30,25 @@ class LockStatePanel extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const [ lockStateClass, lockIconClass, lockTextKey ] = this.props.locked let iconClass;
? [ 'is-locked', 'icon-security-locked', 'invite.locked' ] let stateClass;
: [ 'is-unlocked', 'icon-security', 'invite.unlocked' ]; let textKey;
if (this.props.locked) {
iconClass = 'icon-security-locked';
stateClass = 'is-locked';
textKey = 'invite.locked';
} else {
iconClass = 'icon-security';
stateClass = 'is-unlocked';
textKey = 'invite.unlocked';
}
return ( return (
<div className = { `lock-state ${lockStateClass}` }> <div className = { `lock-state ${stateClass}` }>
<span className = { lockIconClass } /> <span className = { iconClass } />
<span> <span>
{ this.props.t(lockTextKey) } { this.props.t(textKey) }
</span> </span>
</div> </div>
); );

View File

@ -8,12 +8,12 @@ import LockStatePanel from './LockStatePanel';
import RemovePasswordForm from './RemovePasswordForm'; import RemovePasswordForm from './RemovePasswordForm';
/** /**
* React component for displaying the current room lock state as well as * React {@code Component} for displaying the current room lock state as well as
* exposing features to modify the room lock. * exposing features to modify the room lock.
*/ */
class PasswordContainer extends Component { class PasswordContainer extends Component {
/** /**
* PasswordContainer component's property types. * {@code PasswordContainer}'s property types.
* *
* @static * @static
*/ */
@ -49,7 +49,7 @@ class PasswordContainer extends Component {
} }
/** /**
* Initializes a new PasswordContainer instance. * Initializes a new {@code PasswordContainer} instance.
* *
* @param {Object} props - The read-only properties with which the new * @param {Object} props - The read-only properties with which the new
* instance is to be initialized. * instance is to be initialized.
@ -58,9 +58,16 @@ class PasswordContainer extends Component {
super(props); super(props);
this.state = { this.state = {
/**
* Whether or not the form to edit the password should display. If
* true, the form should display.
*
* @type {boolean}
*/
isEditingPassword: false isEditingPassword: false
}; };
// Bind event handlers so they are only bound once for every instance.
this._onTogglePasswordEdit = this._onTogglePasswordEdit.bind(this); this._onTogglePasswordEdit = this._onTogglePasswordEdit.bind(this);
} }
@ -105,12 +112,14 @@ class PasswordContainer extends Component {
return null; return null;
} }
return this.props.locked return (
this.props.locked
? <RemovePasswordForm ? <RemovePasswordForm
conference = { this.props.conference } conference = { this.props.conference }
lockedLocally = { this.props.locked === LOCKED_LOCALLY } lockedLocally = { this.props.locked === LOCKED_LOCALLY }
password = { this.props.password } /> password = { this.props.password } />
: <AddPasswordForm conference = { this.props.conference } />; : <AddPasswordForm conference = { this.props.conference } />
);
} }
/** /**

View File

@ -5,11 +5,11 @@ import { setPassword } from '../../base/conference';
import { translate } from '../../base/i18n'; import { translate } from '../../base/i18n';
/** /**
* A React Component for removing a lock from a JitsiConference. * A React {@code Component} for removing a lock from a JitsiConference.
*/ */
class RemovePasswordForm extends Component { class RemovePasswordForm extends Component {
/** /**
* RemovePasswordForm component's property types. * {@code RemovePasswordForm}'s property types.
* *
* @static * @static
*/ */
@ -43,7 +43,7 @@ class RemovePasswordForm extends Component {
} }
/** /**
* Initializes a new RemovePasswordForm instance. * Initializes a new {@code RemovePasswordForm} instance.
* *
* @param {Object} props - The read-only properties with which the new * @param {Object} props - The read-only properties with which the new
* instance is to be initialized. * instance is to be initialized.
@ -51,6 +51,7 @@ class RemovePasswordForm extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
// Bind event handlers so they are only bound once for every instance.
this._onClick = this._onClick.bind(this); this._onClick = this._onClick.bind(this);
} }
@ -83,15 +84,15 @@ class RemovePasswordForm extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_getPasswordPreviewText() { _getPasswordPreviewText() {
const { lockedLocally, password, t } = this.props;
return ( return (
<span> <span>
<span> <span>
{ `${this.props.t('dialog.currentPassword')} ` } { `${t('dialog.currentPassword')} ` }
</span> </span>
<span className = 'remove-password-current'> <span className = 'remove-password-current'>
{ this.props.lockedLocally { lockedLocally ? password : t('passwordSetRemotely') }
? this.props.password
: this.props.t('passwordSetRemotely') }
</span> </span>
</span> </span>
); );
@ -104,7 +105,7 @@ class RemovePasswordForm extends Component {
* @returns {void} * @returns {void}
*/ */
_onClick() { _onClick() {
const conference = this.props.conference; const { conference } = this.props;
this.props.dispatch(setPassword( this.props.dispatch(setPassword(
conference, conference,

View File

@ -5,12 +5,12 @@ import { translate } from '../../base/i18n';
const logger = require('jitsi-meet-logger').getLogger(__filename); const logger = require('jitsi-meet-logger').getLogger(__filename);
/** /**
* A React Component for displaying a value with a copy button that can be * A React {@code Component} for displaying a value with a copy button to copy
* clicked to copy the value onto the clipboard. * the value into the clipboard.
*/ */
class ShareLinkForm extends Component { class ShareLinkForm extends Component {
/** /**
* ShareLinkForm component's property types. * {@code ShareLinkForm}'s property types.
* *
* @static * @static
*/ */
@ -21,13 +21,13 @@ class ShareLinkForm extends Component {
t: React.PropTypes.func, t: React.PropTypes.func,
/** /**
* The value to be displayed and copied onto the clipboard. * The value to be displayed and copied into the clipboard.
*/ */
toCopy: React.PropTypes.string toCopy: React.PropTypes.string
} }
/** /**
* Initializes a new ShareLinkForm instance. * Initializes a new {@code ShareLinkForm} instance.
* *
* @param {Object} props - The read-only properties with which the new * @param {Object} props - The read-only properties with which the new
* instance is to be initialized. * instance is to be initialized.
@ -35,8 +35,17 @@ class ShareLinkForm extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
/**
* The internal reference to the DOM/HTML element backing the React
* {@code Component} input with id {@code inviteLinkRef}. It is
* necessary for the implementation of copying to the clipboard.
*
* @private
* @type {HTMLInputElement}
*/
this._inputElement = null; this._inputElement = null;
// Bind event handlers so they are only bound once for every instance.
this._onClick = this._onClick.bind(this); this._onClick = this._onClick.bind(this);
this._setInput = this._setInput.bind(this); this._setInput = this._setInput.bind(this);
} }
@ -48,15 +57,15 @@ class ShareLinkForm extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const inputValue = this.props.toCopy const { t } = this.props;
|| this.props.t('inviteUrlDefaultMsg'); const inputValue = this.props.toCopy || t('inviteUrlDefaultMsg');
// FIXME input is used here instead of atlaskit field-text because // FIXME An input HTML element is used here instead of atlaskit's
// field-text does not currently support readonly // field-text because the latter does not currently support readOnly.
return ( return (
<div className = 'form-control'> <div className = 'form-control'>
<label className = 'form-control__label'> <label className = 'form-control__label'>
{ this.props.t('dialog.shareLink') } { t('dialog.shareLink') }
</label> </label>
<div className = 'form-control__container'> <div className = 'form-control__container'>
<input <input
@ -71,7 +80,7 @@ class ShareLinkForm extends Component {
'button-control button-control_light copyInviteLink' 'button-control button-control_light copyInviteLink'
onClick = { this._onClick } onClick = { this._onClick }
type = 'button'> type = 'button'>
{ this.props.t('dialog.copy') } { t('dialog.copy') }
</button> </button>
</div> </div>
</div> </div>
@ -95,10 +104,11 @@ class ShareLinkForm extends Component {
} }
/** /**
* Sets the internal reference to the DOM element for the input field so it * Sets the internal reference to the DOM/HTML element backing the React
* may be accessed directly. * {@code Component} input with id {@code inviteLinkRef}.
* *
* @param {Object} element - DOM element for the component's input. * @param {HTMLInputElement} element - The DOM/HTML element for this
* {@code Component}'s input.
* @private * @private
* @returns {void} * @returns {void}
*/ */

View File

@ -1,7 +1,8 @@
/* global APP */ /* global APP */
import AKFieldText from '@atlaskit/field-text';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import AKFieldText from '@atlaskit/field-text';
import UIEvents from '../../../../service/UI/UIEvents'; import UIEvents from '../../../../service/UI/UIEvents';
@ -39,7 +40,9 @@ class PasswordRequiredPrompt extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { password: '' }; this.state = {
password: ''
};
this._onPasswordChanged = this._onPasswordChanged.bind(this); this._onPasswordChanged = this._onPasswordChanged.bind(this);
this._onSubmit = this._onSubmit.bind(this); this._onSubmit = this._onSubmit.bind(this);
@ -69,19 +72,18 @@ class PasswordRequiredPrompt extends Component {
* @protected * @protected
*/ */
_renderBody() { _renderBody() {
const { t } = this.props;
return ( return (
<div> <div>
<AKFieldText <AKFieldText
compact = { true } compact = { true }
label = { t('dialog.passwordLabel') } label = { this.props.t('dialog.passwordLabel') }
name = 'lockKey' name = 'lockKey'
onChange = { this._onPasswordChanged } onChange = { this._onPasswordChanged }
shouldFitContainer = { true } shouldFitContainer = { true }
type = 'text' type = 'text'
value = { this.state.password } /> value = { this.state.password } />
</div>); </div>
);
} }
/** /**
@ -92,7 +94,9 @@ class PasswordRequiredPrompt extends Component {
* @returns {void} * @returns {void}
*/ */
_onPasswordChanged(event) { _onPasswordChanged(event) {
this.setState({ password: event.target.value }); this.setState({
password: event.target.value
});
} }
/** /**
@ -102,25 +106,26 @@ class PasswordRequiredPrompt extends Component {
* @returns {void} * @returns {void}
*/ */
_onSubmit() { _onSubmit() {
const conference = this.props.conference; const { conference } = this.props;
// we received that password is required, but user is trying // We received that password is required, but user is trying anyway to
// anyway to login without a password, mark room as not // login without a password. Mark the room as not locked in case she
// locked in case he succeeds (maybe someone removed the // succeeds (maybe someone removed the password meanwhile). If it is
// password meanwhile), if it is still locked another // still locked, another password required will be received and the room
// password required will be received and the room again // again will be marked as locked.
// will be marked as locked.
if (!this.state.password || this.state.password === '') { if (!this.state.password || this.state.password === '') {
// XXX temporary solution while some components are not listening // XXX Temporary solution while some components are not listening
// for lock state updates in redux // for lock state updates in redux.
APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, false); APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, false);
} }
this.props.dispatch(setPassword( this.props.dispatch(
conference, conference.join, this.state.password)); setPassword(conference, conference.join, this.state.password));
// we have used the password lets clean it // We have used the password so let's clean it.
this.setState({ password: undefined }); this.setState({
password: undefined
});
return true; return true;
} }

View File

@ -1,12 +1,15 @@
/** /**
* The room lock state where the password was set by the current user. * The conference/room lock state which identifies that the password was set by
* the current/local participant/user.
* *
* @type {string} * @type {string}
*/ */
export const LOCKED_LOCALLY = 'LOCKED_LOCALLY'; export const LOCKED_LOCALLY = 'LOCKED_LOCALLY';
/** /**
* The room lock state where the password was set by a remote user. * The conference/room lock state which identifies that the password was set by
* a remote participant/user.
*
* @type {string} * @type {string}
*/ */
export const LOCKED_REMOTELY = 'LOCKED_REMOTELY'; export const LOCKED_REMOTELY = 'LOCKED_REMOTELY';

View File

@ -1,5 +1,4 @@
/* global APP */ /* global APP */
const logger = require('jitsi-meet-logger').getLogger(__filename);
import UIEvents from '../../../service/UI/UIEvents'; import UIEvents from '../../../service/UI/UIEvents';
@ -8,11 +7,13 @@ import {
LOCK_STATE_CHANGED, LOCK_STATE_CHANGED,
SET_PASSWORD_FAILED SET_PASSWORD_FAILED
} from '../base/conference'; } from '../base/conference';
import JitsiMeetJS from '../base/lib-jitsi-meet'; import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
import { MiddlewareRegistry } from '../base/redux'; import { MiddlewareRegistry } from '../base/redux';
import { _showPasswordDialog } from './actions'; import { _showPasswordDialog } from './actions';
const logger = require('jitsi-meet-logger').getLogger(__filename);
/** /**
* Middleware that captures conference failed and checks for password required * Middleware that captures conference failed and checks for password required
* error and requests a dialog for user to enter password. * error and requests a dialog for user to enter password.
@ -21,41 +22,39 @@ import { _showPasswordDialog } from './actions';
* @returns {Function} * @returns {Function}
*/ */
MiddlewareRegistry.register(store => next => action => { MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case CONFERENCE_FAILED: { case CONFERENCE_FAILED: {
const JitsiConferenceErrors = JitsiMeetJS.errors.conference; const { conference, error } = action;
if (action.conference if (conference && error === JitsiConferenceErrors.PASSWORD_REQUIRED) {
&& JitsiConferenceErrors.PASSWORD_REQUIRED === action.error) { // XXX Temporary solution while some components are not listening
// XXX temporary solution while some components are not listening // for lock state updates in redux.
// for lock state updates in redux
if (typeof APP !== 'undefined') { if (typeof APP !== 'undefined') {
APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, true); APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, true);
} }
store.dispatch(_showPasswordDialog(action.conference)); store.dispatch(_showPasswordDialog(conference));
} }
break; break;
} }
case LOCK_STATE_CHANGED: {
case LOCK_STATE_CHANGED:
// TODO Remove this logic when all components interested in the lock // TODO Remove this logic when all components interested in the lock
// state change event are moved into react/redux. // state change event are moved into react/redux.
if (typeof APP !== 'undefined') { if (typeof APP !== 'undefined') {
APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, action.locked); APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, action.locked);
} }
break; break;
}
case SET_PASSWORD_FAILED: case SET_PASSWORD_FAILED:
return _notifySetPasswordError(store, next, action); return _setPasswordFailed(store, next, action);
} }
return next(action); return next(action);
}); });
/** /**
* Handles errors that occur when a password is failed to be set. * Handles errors that occur when a password fails to be set.
* *
* @param {Store} store - The Redux store in which the specified action is being * @param {Store} store - The Redux store in which the specified action is being
* dispatched. * dispatched.
@ -67,20 +66,24 @@ MiddlewareRegistry.register(store => next => action => {
* @returns {Object} The new state that is the result of the reduction of the * @returns {Object} The new state that is the result of the reduction of the
* specified action. * specified action.
*/ */
function _notifySetPasswordError(store, next, action) { function _setPasswordFailed(store, next, action) {
if (typeof APP !== 'undefined') { if (typeof APP !== 'undefined') {
// TODO remove this logic when displaying of error messages on web is // TODO Remove this logic when displaying of error messages on web is
// handled through react/redux // handled through react/redux.
if (action.error const { error } = action;
=== JitsiMeetJS.errors.conference.PASSWORD_NOT_SUPPORTED) { let title;
let message;
if (error === JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED) {
logger.warn('room passwords not supported'); logger.warn('room passwords not supported');
APP.UI.messageHandler.showError( title = 'dialog.warning';
'dialog.warning', 'dialog.passwordNotSupported'); message = 'dialog.passwordNotSupported';
} else { } else {
logger.warn('setting password failed', action.error); logger.warn('setting password failed', error);
APP.UI.messageHandler.showError( title = 'dialog.lockTitle';
'dialog.lockTitle', 'dialog.lockMessage'); message = 'dialog.lockMessage';
} }
APP.UI.messageHandler.showError(title, message);
} }
return next(action); return next(action);