Przeglądaj źródła

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.
master
Lyubo Marinov 8 lat temu
rodzic
commit
55c3f5ddff

+ 6
- 9
conference.js Wyświetl plik

@@ -409,12 +409,9 @@ class ConferenceConnector {
409 409
             break;
410 410
 
411 411
             // not enough rights to create conference
412
-        case ConferenceErrors.AUTHENTICATION_REQUIRED:
413
-            {
414
-                // schedule reconnect to check if someone else created the room
415
-                this.reconnectTimeout = setTimeout(function () {
416
-                    room.join();
417
-                }, 5000);
412
+        case ConferenceErrors.AUTHENTICATION_REQUIRED: {
413
+                // Schedule reconnect to check if someone else created the room.
414
+                this.reconnectTimeout = setTimeout(() => room.join(), 5000);
418 415
 
419 416
                 const { password }
420 417
                     = APP.store.getState()['features/base/conference'];
@@ -1449,9 +1446,9 @@ export default {
1449 1446
             APP.UI.changeDisplayName(id, formattedDisplayName);
1450 1447
         });
1451 1448
 
1452
-        room.on(ConferenceEvents.LOCK_STATE_CHANGED, (...args) => {
1453
-            APP.store.dispatch(lockStateChanged(room, ...args));
1454
-        });
1449
+        room.on(
1450
+            ConferenceEvents.LOCK_STATE_CHANGED,
1451
+            (...args) => APP.store.dispatch(lockStateChanged(room, ...args)));
1455 1452
 
1456 1453
         room.on(ConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
1457 1454
                 (participant, name, oldValue, newValue) => {

+ 6
- 6
css/modals/invite/_invite.scss Wyświetl plik

@@ -24,18 +24,18 @@
24 24
             margin-top: 10px;
25 25
         }
26 26
 
27
-        .password-overview-toggle-edit,
28
-        .remove-password-link {
29
-            cursor: pointer;
30
-            text-decoration: none;
31
-        }
32
-
33 27
         .password-overview-status,
34 28
         .remove-password {
35 29
             display: flex;
36 30
             justify-content: space-between;
37 31
         }
38 32
 
33
+        .password-overview-toggle-edit,
34
+        .remove-password-link {
35
+            cursor: pointer;
36
+            text-decoration: none;
37
+        }
38
+
39 39
         .remove-password {
40 40
             margin-top: 15px;
41 41
         }

+ 4
- 6
modules/UI/side_pannels/contactlist/ContactList.js Wyświetl plik

@@ -24,9 +24,7 @@ class ContactList {
24 24
      * @returns {Boolean}
25 25
      */
26 26
     isLocked() {
27
-        const conference = APP.store.getState()['features/base/conference'];
28
-
29
-        return conference.locked;
27
+        return APP.store.getState()['features/base/conference'].locked;
30 28
     }
31 29
 
32 30
     /**
@@ -36,9 +34,9 @@ class ContactList {
36 34
      * @param isLocal
37 35
      */
38 36
     addContact(id, isLocal) {
39
-        let isExist = this.contacts.some((el) => el.id === id);
37
+        const exists = this.contacts.some(el => el.id === id);
40 38
 
41
-        if (!isExist) {
39
+        if (!exists) {
42 40
             let newContact = new Contact({ id, isLocal });
43 41
             this.contacts.push(newContact);
44 42
             APP.UI.emitEvent(UIEvents.CONTACT_ADDED, { id, isLocal });
@@ -92,4 +90,4 @@ class ContactList {
92 90
     }
93 91
 }
94 92
 
95
-export default ContactList;
93
+export default ContactList;

+ 20
- 11
modules/UI/side_pannels/contactlist/ContactListView.js Wyświetl plik

@@ -1,5 +1,4 @@
1 1
 /* global $, APP, interfaceConfig */
2
-const logger = require("jitsi-meet-logger").getLogger(__filename);
3 2
 
4 3
 import { openInviteDialog } from '../../../../react/features/invite';
5 4
 
@@ -7,6 +6,8 @@ import Avatar from '../../avatar/Avatar';
7 6
 import UIEvents from '../../../../service/UI/UIEvents';
8 7
 import UIUtil from '../../util/UIUtil';
9 8
 
9
+const logger = require('jitsi-meet-logger').getLogger(__filename);
10
+
10 11
 let numberOfContacts = 0;
11 12
 const sidePanelsContainerId = 'sideToolbarContainer';
12 13
 const htmlStr = `
@@ -169,20 +170,28 @@ var ContactListView = {
169 170
         APP.UI.addListener(UIEvents.USER_AVATAR_CHANGED, changeAvatar);
170 171
         APP.UI.addListener(UIEvents.DISPLAY_NAME_CHANGED, displayNameChange);
171 172
     },
173
+
172 174
     /**
173 175
      * Updates the view according to the passed in lock state.
174 176
      *
175
-     * @param {boolean} isLocked - True if the locked UI state should display.
177
+     * @param {boolean} locked - True to display the locked UI state or false to
178
+     * display the unlocked UI state.
176 179
      */
177
-    setLockDisplay(isLocked) {
178
-        const showKey = isLocked ? this.lockKey : this.unlockKey;
179
-        const hideKey = !isLocked ? this.lockKey : this.unlockKey;
180
-        const showId = `contactList${showKey}`;
181
-        const hideId = `contactList${hideKey}`;
182
-
183
-        $(`#${showId}`).show();
184
-        $(`#${hideId}`).hide();
180
+    setLockDisplay(locked) {
181
+        let hideKey, showKey;
182
+
183
+        if (locked) {
184
+            hideKey = this.unlockKey;
185
+            showKey = this.lockKey;
186
+        } else {
187
+            hideKey = this.lockKey;
188
+            showKey = this.unlockKey;
189
+        }
190
+
191
+        $(`#contactList${hideKey}`).hide();
192
+        $(`#contactList${showKey}`).show();
185 193
     },
194
+
186 195
     /**
187 196
      * Indicates if the chat is currently visible.
188 197
      *
@@ -277,4 +286,4 @@ var ContactListView = {
277 286
     }
278 287
 };
279 288
 
280
-export default ContactListView;
289
+export default ContactListView;

+ 1
- 1
react/features/base/conference/actionTypes.js Wyświetl plik

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

+ 14
- 8
react/features/base/conference/reducer.js Wyświetl plik

@@ -85,6 +85,14 @@ function _conferenceFailed(state, action) {
85 85
             audioOnlyVideoMuted: undefined,
86 86
             conference: undefined,
87 87
             leaving: undefined,
88
+
89
+            /**
90
+             * The indicator of how the conference/room is locked. If falsy, the
91
+             * conference/room is unlocked; otherwise, it's either
92
+             * {@code LOCKED_LOCALLY| or {@code LOCKED_REMOTELY}.
93
+             *
94
+             * @type {string}
95
+             */
88 96
             locked: passwordRequired ? LOCKED_REMOTELY : undefined,
89 97
             password: undefined,
90 98
 
@@ -211,14 +219,14 @@ function _lockStateChanged(state, action) {
211 219
         return state;
212 220
     }
213 221
 
214
-    let lockState;
222
+    let locked;
215 223
 
216 224
     if (action.locked) {
217
-        lockState = state.locked || LOCKED_REMOTELY;
225
+        locked = state.locked || LOCKED_REMOTELY;
218 226
     }
219 227
 
220 228
     return setStateProperties(state, {
221
-        locked: lockState,
229
+        locked,
222 230
         password: action.locked ? state.password : null
223 231
     });
224 232
 }
@@ -265,7 +273,7 @@ function _setPassword(state, action) {
265 273
     const conference = action.conference;
266 274
 
267 275
     switch (action.method) {
268
-    case conference.join: {
276
+    case conference.join:
269 277
         if (state.passwordRequired === conference) {
270 278
             return (
271 279
                 setStateProperties(state, {
@@ -280,16 +288,14 @@ function _setPassword(state, action) {
280 288
                     passwordRequired: undefined
281 289
                 }));
282 290
         }
283
-
284 291
         break;
285
-    }
286
-    case conference.lock: {
292
+
293
+    case conference.lock:
287 294
         return setStateProperties(state, {
288 295
             locked: action.password ? LOCKED_LOCALLY : undefined,
289 296
             password: action.password
290 297
         });
291 298
     }
292
-    }
293 299
 
294 300
     return state;
295 301
 }

+ 3
- 5
react/features/invite/actions.js Wyświetl plik

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

+ 16
- 7
react/features/invite/components/AddPasswordForm.js Wyświetl plik

@@ -5,11 +5,11 @@ import { setPassword } from '../../base/conference';
5 5
 import { translate } from '../../base/i18n';
6 6
 
7 7
 /**
8
- * A React Component for locking a JitsiConference with a password.
8
+ * A React {@code Component} for locking a JitsiConference with a password.
9 9
  */
10 10
 class AddPasswordForm extends Component {
11 11
     /**
12
-     * AddPasswordForm component's property types.
12
+     * {@code AddPasswordForm}'s property types.
13 13
      *
14 14
      * @static
15 15
      */
@@ -33,7 +33,7 @@ class AddPasswordForm extends Component {
33 33
     }
34 34
 
35 35
     /**
36
-     * Initializes a new AddPasswordForm instance.
36
+     * Initializes a new {@code AddPasswordForm} instance.
37 37
      *
38 38
      * @param {Object} props - The read-only properties with which the new
39 39
      * instance is to be initialized.
@@ -42,9 +42,17 @@ class AddPasswordForm extends Component {
42 42
         super(props);
43 43
 
44 44
         this.state = {
45
+            /**
46
+             * The current value to display in {@code AddPasswordForm}
47
+             * component's input field. The value is also used as the desired
48
+             * new password when creating a {@code setPassword} action.
49
+             *
50
+             * @type {string}
51
+             */
45 52
             password: ''
46 53
         };
47 54
 
55
+        // Bind event handlers so they are only bound once for every instance.
48 56
         this._onKeyDown = this._onKeyDown.bind(this);
49 57
         this._onPasswordChange = this._onPasswordChange.bind(this);
50 58
         this._onSubmit = this._onSubmit.bind(this);
@@ -57,6 +65,8 @@ class AddPasswordForm extends Component {
57 65
      * @returns {ReactElement}
58 66
      */
59 67
     render() {
68
+        const { t } = this.props;
69
+
60 70
         return (
61 71
             <div
62 72
                 className = 'form-control'
@@ -68,8 +78,7 @@ class AddPasswordForm extends Component {
68 78
                         id = 'newPasswordInput'
69 79
                         onChange = { this._onPasswordChange }
70 80
                         onKeyDown = { this._onKeyDown }
71
-                        placeholder
72
-                            = { this.props.t('dialog.createPassword') }
81
+                        placeholder = { t('dialog.createPassword') }
73 82
                         type = 'text' />
74 83
                     <button
75 84
                         className = 'button-control button-control_light'
@@ -77,7 +86,7 @@ class AddPasswordForm extends Component {
77 86
                         id = 'addPasswordBtn'
78 87
                         onClick = { this._onSubmit }
79 88
                         type = 'button'>
80
-                        { this.props.t('dialog.add') }
89
+                        { t('dialog.add') }
81 90
                     </button>
82 91
                 </div>
83 92
             </div>
@@ -122,7 +131,7 @@ class AddPasswordForm extends Component {
122 131
             return;
123 132
         }
124 133
 
125
-        const conference = this.props.conference;
134
+        const { conference } = this.props;
126 135
 
127 136
         this.props.dispatch(setPassword(
128 137
             conference,

+ 16
- 10
react/features/invite/components/InviteDialog.js Wyświetl plik

@@ -13,12 +13,13 @@ import PasswordContainer from './PasswordContainer';
13 13
 import ShareLinkForm from './ShareLinkForm';
14 14
 
15 15
 /**
16
- * A React Component for displaying other components responsible for copying the
17
- * current conference url and for setting or removing a conference password.
16
+ * A React {@code Component} for displaying other components responsible for
17
+ * copying the current conference url and for setting or removing a conference
18
+ * password.
18 19
  */
19 20
 class InviteDialog extends Component {
20 21
     /**
21
-     * InviteDialog component's property types.
22
+     * {@code InviteDialog} component's property types.
22 23
      *
23 24
      * @static
24 25
      */
@@ -61,19 +62,23 @@ class InviteDialog extends Component {
61 62
      * @returns {ReactElement}
62 63
      */
63 64
     render() {
65
+        const { _conference } = this.props;
66
+        const titleString
67
+            = this.props.t(
68
+                'invite.inviteTo',
69
+                { conferenceName: _conference.room });
70
+
64 71
         return (
65 72
             <Dialog
66 73
                 cancelDisabled = { true }
67 74
                 okTitleKey = 'dialog.done'
68
-                titleString = { this.props.t(
69
-                    'invite.inviteTo',
70
-                    { conferenceName: this.props._conference.room }) } >
75
+                titleString = { titleString }>
71 76
                 <div className = 'invite-dialog'>
72 77
                     <ShareLinkForm toCopy = { this.props.conferenceUrl } />
73 78
                     <PasswordContainer
74
-                        conference = { this.props._conference.conference }
75
-                        locked = { this.props._conference.locked }
76
-                        password = { this.props._conference.password }
79
+                        conference = { _conference.conference }
80
+                        locked = { _conference.locked }
81
+                        password = { _conference.password }
77 82
                         showPasswordEdit = { this.props._isModerator } />
78 83
                 </div>
79 84
             </Dialog>
@@ -82,7 +87,8 @@ class InviteDialog extends Component {
82 87
 }
83 88
 
84 89
 /**
85
- * Maps (parts of) the Redux state to the associated InviteDialog's props.
90
+ * Maps (parts of) the Redux state to the associated {@code InviteDialog}'s
91
+ * props.
86 92
  *
87 93
  * @param {Object} state - The Redux state.
88 94
  * @private

+ 17
- 7
react/features/invite/components/LockStatePanel.js Wyświetl plik

@@ -7,7 +7,7 @@ import { translate } from '../../base/i18n';
7 7
  */
8 8
 class LockStatePanel extends Component {
9 9
     /**
10
-     * LockStatePanel component's property types.
10
+     * {@code LockStatePanel}'s property types.
11 11
      *
12 12
      * @static
13 13
      */
@@ -30,15 +30,25 @@ class LockStatePanel extends Component {
30 30
      * @returns {ReactElement}
31 31
      */
32 32
     render() {
33
-        const [ lockStateClass, lockIconClass, lockTextKey ] = this.props.locked
34
-            ? [ 'is-locked', 'icon-security-locked', 'invite.locked' ]
35
-            : [ 'is-unlocked', 'icon-security', 'invite.unlocked' ];
33
+        let iconClass;
34
+        let stateClass;
35
+        let textKey;
36
+
37
+        if (this.props.locked) {
38
+            iconClass = 'icon-security-locked';
39
+            stateClass = 'is-locked';
40
+            textKey = 'invite.locked';
41
+        } else {
42
+            iconClass = 'icon-security';
43
+            stateClass = 'is-unlocked';
44
+            textKey = 'invite.unlocked';
45
+        }
36 46
 
37 47
         return (
38
-            <div className = { `lock-state ${lockStateClass}` }>
39
-                <span className = { lockIconClass } />
48
+            <div className = { `lock-state ${stateClass}` }>
49
+                <span className = { iconClass } />
40 50
                 <span>
41
-                    { this.props.t(lockTextKey) }
51
+                    { this.props.t(textKey) }
42 52
                 </span>
43 53
             </div>
44 54
         );

+ 18
- 9
react/features/invite/components/PasswordContainer.js Wyświetl plik

@@ -8,12 +8,12 @@ import LockStatePanel from './LockStatePanel';
8 8
 import RemovePasswordForm from './RemovePasswordForm';
9 9
 
10 10
 /**
11
- * React component for displaying the current room lock state as well as
11
+ * React {@code Component} for displaying the current room lock state as well as
12 12
  * exposing features to modify the room lock.
13 13
  */
14 14
 class PasswordContainer extends Component {
15 15
     /**
16
-     * PasswordContainer component's property types.
16
+     * {@code PasswordContainer}'s property types.
17 17
      *
18 18
      * @static
19 19
      */
@@ -49,7 +49,7 @@ class PasswordContainer extends Component {
49 49
     }
50 50
 
51 51
     /**
52
-     * Initializes a new PasswordContainer instance.
52
+     * Initializes a new {@code PasswordContainer} instance.
53 53
      *
54 54
      * @param {Object} props - The read-only properties with which the new
55 55
      * instance is to be initialized.
@@ -58,9 +58,16 @@ class PasswordContainer extends Component {
58 58
         super(props);
59 59
 
60 60
         this.state = {
61
+            /**
62
+             * Whether or not the form to edit the password should display. If
63
+             * true, the form should display.
64
+             *
65
+             * @type {boolean}
66
+             */
61 67
             isEditingPassword: false
62 68
         };
63 69
 
70
+        // Bind event handlers so they are only bound once for every instance.
64 71
         this._onTogglePasswordEdit = this._onTogglePasswordEdit.bind(this);
65 72
     }
66 73
 
@@ -105,12 +112,14 @@ class PasswordContainer extends Component {
105 112
             return null;
106 113
         }
107 114
 
108
-        return this.props.locked
109
-            ? <RemovePasswordForm
110
-                conference = { this.props.conference }
111
-                lockedLocally = { this.props.locked === LOCKED_LOCALLY }
112
-                password = { this.props.password } />
113
-            : <AddPasswordForm conference = { this.props.conference } />;
115
+        return (
116
+            this.props.locked
117
+                ? <RemovePasswordForm
118
+                    conference = { this.props.conference }
119
+                    lockedLocally = { this.props.locked === LOCKED_LOCALLY }
120
+                    password = { this.props.password } />
121
+                : <AddPasswordForm conference = { this.props.conference } />
122
+        );
114 123
     }
115 124
 
116 125
     /**

+ 9
- 8
react/features/invite/components/RemovePasswordForm.js Wyświetl plik

@@ -5,11 +5,11 @@ import { setPassword } from '../../base/conference';
5 5
 import { translate } from '../../base/i18n';
6 6
 
7 7
 /**
8
- * A React Component for removing a lock from a JitsiConference.
8
+ * A React {@code Component} for removing a lock from a JitsiConference.
9 9
  */
10 10
 class RemovePasswordForm extends Component {
11 11
     /**
12
-     * RemovePasswordForm component's property types.
12
+     * {@code RemovePasswordForm}'s property types.
13 13
      *
14 14
      * @static
15 15
      */
@@ -43,7 +43,7 @@ class RemovePasswordForm extends Component {
43 43
     }
44 44
 
45 45
     /**
46
-     * Initializes a new RemovePasswordForm instance.
46
+     * Initializes a new {@code RemovePasswordForm} instance.
47 47
      *
48 48
      * @param {Object} props - The read-only properties with which the new
49 49
      * instance is to be initialized.
@@ -51,6 +51,7 @@ class RemovePasswordForm extends Component {
51 51
     constructor(props) {
52 52
         super(props);
53 53
 
54
+        // Bind event handlers so they are only bound once for every instance.
54 55
         this._onClick = this._onClick.bind(this);
55 56
     }
56 57
 
@@ -83,15 +84,15 @@ class RemovePasswordForm extends Component {
83 84
      * @returns {ReactElement}
84 85
      */
85 86
     _getPasswordPreviewText() {
87
+        const { lockedLocally, password, t } = this.props;
88
+
86 89
         return (
87 90
             <span>
88 91
                 <span>
89
-                    { `${this.props.t('dialog.currentPassword')} ` }
92
+                    { `${t('dialog.currentPassword')} ` }
90 93
                 </span>
91 94
                 <span className = 'remove-password-current'>
92
-                    { this.props.lockedLocally
93
-                        ? this.props.password
94
-                        : this.props.t('passwordSetRemotely') }
95
+                    { lockedLocally ? password : t('passwordSetRemotely') }
95 96
                 </span>
96 97
             </span>
97 98
         );
@@ -104,7 +105,7 @@ class RemovePasswordForm extends Component {
104 105
      * @returns {void}
105 106
      */
106 107
     _onClick() {
107
-        const conference = this.props.conference;
108
+        const { conference } = this.props;
108 109
 
109 110
         this.props.dispatch(setPassword(
110 111
             conference,

+ 25
- 15
react/features/invite/components/ShareLinkForm.js Wyświetl plik

@@ -5,12 +5,12 @@ import { translate } from '../../base/i18n';
5 5
 const logger = require('jitsi-meet-logger').getLogger(__filename);
6 6
 
7 7
 /**
8
- * A React Component for displaying a value with a copy button that can be
9
- * clicked to copy the value onto the clipboard.
8
+ * A React {@code Component} for displaying a value with a copy button to copy
9
+ * the value into the clipboard.
10 10
  */
11 11
 class ShareLinkForm extends Component {
12 12
     /**
13
-     * ShareLinkForm component's property types.
13
+     * {@code ShareLinkForm}'s property types.
14 14
      *
15 15
      * @static
16 16
      */
@@ -20,14 +20,14 @@ class ShareLinkForm extends Component {
20 20
          */
21 21
         t: React.PropTypes.func,
22 22
 
23
-       /**
24
-         * The value to be displayed and copied onto the clipboard.
23
+        /**
24
+         * The value to be displayed and copied into the clipboard.
25 25
          */
26 26
         toCopy: React.PropTypes.string
27 27
     }
28 28
 
29 29
     /**
30
-     * Initializes a new ShareLinkForm instance.
30
+     * Initializes a new {@code ShareLinkForm} instance.
31 31
      *
32 32
      * @param {Object} props - The read-only properties with which the new
33 33
      * instance is to be initialized.
@@ -35,8 +35,17 @@ class ShareLinkForm extends Component {
35 35
     constructor(props) {
36 36
         super(props);
37 37
 
38
+        /**
39
+         * The internal reference to the DOM/HTML element backing the React
40
+         * {@code Component} input with id {@code inviteLinkRef}. It is
41
+         * necessary for the implementation of copying to the clipboard.
42
+         *
43
+         * @private
44
+         * @type {HTMLInputElement}
45
+         */
38 46
         this._inputElement = null;
39 47
 
48
+        // Bind event handlers so they are only bound once for every instance.
40 49
         this._onClick = this._onClick.bind(this);
41 50
         this._setInput = this._setInput.bind(this);
42 51
     }
@@ -48,15 +57,15 @@ class ShareLinkForm extends Component {
48 57
      * @returns {ReactElement}
49 58
      */
50 59
     render() {
51
-        const inputValue = this.props.toCopy
52
-            || this.props.t('inviteUrlDefaultMsg');
60
+        const { t } = this.props;
61
+        const inputValue = this.props.toCopy || t('inviteUrlDefaultMsg');
53 62
 
54
-        // FIXME input is used here instead of atlaskit field-text because
55
-        // field-text does not currently support readonly
63
+        // FIXME An input HTML element is used here instead of atlaskit's
64
+        // field-text because the latter does not currently support readOnly.
56 65
         return (
57 66
             <div className = 'form-control'>
58 67
                 <label className = 'form-control__label'>
59
-                    { this.props.t('dialog.shareLink') }
68
+                    { t('dialog.shareLink') }
60 69
                 </label>
61 70
                 <div className = 'form-control__container'>
62 71
                     <input
@@ -71,7 +80,7 @@ class ShareLinkForm extends Component {
71 80
                             'button-control button-control_light copyInviteLink'
72 81
                         onClick = { this._onClick }
73 82
                         type = 'button'>
74
-                        { this.props.t('dialog.copy') }
83
+                        { t('dialog.copy') }
75 84
                     </button>
76 85
                 </div>
77 86
             </div>
@@ -95,10 +104,11 @@ class ShareLinkForm extends Component {
95 104
     }
96 105
 
97 106
     /**
98
-     * Sets the internal reference to the DOM element for the input field so it
99
-     * may be accessed directly.
107
+     * Sets the internal reference to the DOM/HTML element backing the React
108
+     * {@code Component} input with id {@code inviteLinkRef}.
100 109
      *
101
-     * @param {Object} element - DOM element for the component's input.
110
+     * @param {HTMLInputElement} element - The DOM/HTML element for this
111
+     * {@code Component}'s input.
102 112
      * @private
103 113
      * @returns {void}
104 114
      */

+ 26
- 21
react/features/room-lock/components/PasswordRequiredPrompt.web.js Wyświetl plik

@@ -1,7 +1,8 @@
1 1
 /* global APP */
2
+
3
+import AKFieldText from '@atlaskit/field-text';
2 4
 import React, { Component } from 'react';
3 5
 import { connect } from 'react-redux';
4
-import AKFieldText from '@atlaskit/field-text';
5 6
 
6 7
 import UIEvents from '../../../../service/UI/UIEvents';
7 8
 
@@ -39,7 +40,9 @@ class PasswordRequiredPrompt extends Component {
39 40
     constructor(props) {
40 41
         super(props);
41 42
 
42
-        this.state = { password: '' };
43
+        this.state = {
44
+            password: ''
45
+        };
43 46
 
44 47
         this._onPasswordChanged = this._onPasswordChanged.bind(this);
45 48
         this._onSubmit = this._onSubmit.bind(this);
@@ -69,19 +72,18 @@ class PasswordRequiredPrompt extends Component {
69 72
      * @protected
70 73
      */
71 74
     _renderBody() {
72
-        const { t } = this.props;
73
-
74 75
         return (
75 76
             <div>
76 77
                 <AKFieldText
77 78
                     compact = { true }
78
-                    label = { t('dialog.passwordLabel') }
79
+                    label = { this.props.t('dialog.passwordLabel') }
79 80
                     name = 'lockKey'
80 81
                     onChange = { this._onPasswordChanged }
81 82
                     shouldFitContainer = { true }
82 83
                     type = 'text'
83 84
                     value = { this.state.password } />
84
-            </div>);
85
+            </div>
86
+        );
85 87
     }
86 88
 
87 89
     /**
@@ -92,7 +94,9 @@ class PasswordRequiredPrompt extends Component {
92 94
      * @returns {void}
93 95
      */
94 96
     _onPasswordChanged(event) {
95
-        this.setState({ password: event.target.value });
97
+        this.setState({
98
+            password: event.target.value
99
+        });
96 100
     }
97 101
 
98 102
     /**
@@ -102,25 +106,26 @@ class PasswordRequiredPrompt extends Component {
102 106
      * @returns {void}
103 107
      */
104 108
     _onSubmit() {
105
-        const conference = this.props.conference;
106
-
107
-        // we received that password is required, but user is trying
108
-        // anyway to login without a password, mark room as not
109
-        // locked in case he succeeds (maybe someone removed the
110
-        // password meanwhile), if it is still locked another
111
-        // password required will be received and the room again
112
-        // will be marked as locked.
109
+        const { conference } = this.props;
110
+
111
+        // We received that password is required, but user is trying anyway to
112
+        // login without a password. Mark the room as not locked in case she
113
+        // succeeds (maybe someone removed the password meanwhile). If it is
114
+        // still locked, another password required will be received and the room
115
+        // again will be marked as locked.
113 116
         if (!this.state.password || this.state.password === '') {
114
-            // XXX temporary solution while some components are not listening
115
-            // for lock state updates in redux
117
+            // XXX Temporary solution while some components are not listening
118
+            // for lock state updates in redux.
116 119
             APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, false);
117 120
         }
118 121
 
119
-        this.props.dispatch(setPassword(
120
-            conference, conference.join, this.state.password));
122
+        this.props.dispatch(
123
+            setPassword(conference, conference.join, this.state.password));
121 124
 
122
-        // we have used the password lets clean it
123
-        this.setState({ password: undefined });
125
+        // We have used the password so let's clean it.
126
+        this.setState({
127
+            password: undefined
128
+        });
124 129
 
125 130
         return true;
126 131
     }

+ 5
- 2
react/features/room-lock/constants.js Wyświetl plik

@@ -1,12 +1,15 @@
1 1
 /**
2
- * The room lock state where the password was set by the current user.
2
+ * The conference/room lock state which identifies that the password was set by
3
+ * the current/local participant/user.
3 4
  *
4 5
  * @type {string}
5 6
  */
6 7
 export const LOCKED_LOCALLY = 'LOCKED_LOCALLY';
7 8
 
8 9
 /**
9
- * The room lock state where the password was set by a remote user.
10
+ * The conference/room lock state which identifies that the password was set by
11
+ * a remote participant/user.
12
+ *
10 13
  * @type {string}
11 14
  */
12 15
 export const LOCKED_REMOTELY = 'LOCKED_REMOTELY';

+ 27
- 24
react/features/room-lock/middleware.js Wyświetl plik

@@ -1,5 +1,4 @@
1 1
 /* global APP */
2
-const logger = require('jitsi-meet-logger').getLogger(__filename);
3 2
 
4 3
 import UIEvents from '../../../service/UI/UIEvents';
5 4
 
@@ -8,11 +7,13 @@ import {
8 7
     LOCK_STATE_CHANGED,
9 8
     SET_PASSWORD_FAILED
10 9
 } from '../base/conference';
11
-import JitsiMeetJS from '../base/lib-jitsi-meet';
10
+import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
12 11
 import { MiddlewareRegistry } from '../base/redux';
13 12
 
14 13
 import { _showPasswordDialog } from './actions';
15 14
 
15
+const logger = require('jitsi-meet-logger').getLogger(__filename);
16
+
16 17
 /**
17 18
  * Middleware that captures conference failed and checks for password required
18 19
  * error and requests a dialog for user to enter password.
@@ -21,41 +22,39 @@ import { _showPasswordDialog } from './actions';
21 22
  * @returns {Function}
22 23
  */
23 24
 MiddlewareRegistry.register(store => next => action => {
24
-
25 25
     switch (action.type) {
26 26
     case CONFERENCE_FAILED: {
27
-        const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
27
+        const { conference, error } = action;
28 28
 
29
-        if (action.conference
30
-            && JitsiConferenceErrors.PASSWORD_REQUIRED === action.error) {
31
-            // XXX temporary solution while some components are not listening
32
-            // for lock state updates in redux
29
+        if (conference && error === JitsiConferenceErrors.PASSWORD_REQUIRED) {
30
+            // XXX Temporary solution while some components are not listening
31
+            // for lock state updates in redux.
33 32
             if (typeof APP !== 'undefined') {
34 33
                 APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, true);
35 34
             }
36 35
 
37
-            store.dispatch(_showPasswordDialog(action.conference));
36
+            store.dispatch(_showPasswordDialog(conference));
38 37
         }
39 38
         break;
40 39
     }
41
-    case LOCK_STATE_CHANGED: {
40
+
41
+    case LOCK_STATE_CHANGED:
42 42
         // TODO Remove this logic when all components interested in the lock
43 43
         // state change event are moved into react/redux.
44 44
         if (typeof APP !== 'undefined') {
45 45
             APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, action.locked);
46 46
         }
47
-
48 47
         break;
49
-    }
48
+
50 49
     case SET_PASSWORD_FAILED:
51
-        return _notifySetPasswordError(store, next, action);
50
+        return _setPasswordFailed(store, next, action);
52 51
     }
53 52
 
54 53
     return next(action);
55 54
 });
56 55
 
57 56
 /**
58
- * Handles errors that occur when a password is failed to be set.
57
+ * Handles errors that occur when a password fails to be set.
59 58
  *
60 59
  * @param {Store} store - The Redux store in which the specified action is being
61 60
  * dispatched.
@@ -67,20 +66,24 @@ MiddlewareRegistry.register(store => next => action => {
67 66
  * @returns {Object} The new state that is the result of the reduction of the
68 67
  * specified action.
69 68
  */
70
-function _notifySetPasswordError(store, next, action) {
69
+function _setPasswordFailed(store, next, action) {
71 70
     if (typeof APP !== 'undefined') {
72
-        // TODO remove this logic when displaying of error messages on web is
73
-        // handled through react/redux
74
-        if (action.error
75
-            === JitsiMeetJS.errors.conference.PASSWORD_NOT_SUPPORTED) {
71
+        // TODO Remove this logic when displaying of error messages on web is
72
+        // handled through react/redux.
73
+        const { error } = action;
74
+        let title;
75
+        let message;
76
+
77
+        if (error === JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED) {
76 78
             logger.warn('room passwords not supported');
77
-            APP.UI.messageHandler.showError(
78
-                'dialog.warning', 'dialog.passwordNotSupported');
79
+            title = 'dialog.warning';
80
+            message = 'dialog.passwordNotSupported';
79 81
         } else {
80
-            logger.warn('setting password failed', action.error);
81
-            APP.UI.messageHandler.showError(
82
-                'dialog.lockTitle', 'dialog.lockMessage');
82
+            logger.warn('setting password failed', error);
83
+            title = 'dialog.lockTitle';
84
+            message = 'dialog.lockMessage';
83 85
         }
86
+        APP.UI.messageHandler.showError(title, message);
84 87
     }
85 88
 
86 89
     return next(action);

Ładowanie…
Anuluj
Zapisz