Ver código fonte

Flow, coding style

master
Lyubo Marinov 7 anos atrás
pai
commit
f53c79ab24

+ 29
- 27
react/features/analytics/functions.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import JitsiMeetJS, { isAnalyticsEnabled } from '../base/lib-jitsi-meet';
2 4
 import { getJitsiMeetGlobalNS, loadScript } from '../base/util';
3 5
 
@@ -13,7 +15,7 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
13 15
  * is being dispatched.
14 16
  * @returns {void}
15 17
  */
16
-export function initAnalytics({ getState }) {
18
+export function initAnalytics({ getState }: { getState: Function }) {
17 19
     getJitsiMeetGlobalNS().analyticsHandlers = [];
18 20
     window.analyticsHandlers = []; // Legacy support.
19 21
 
@@ -36,12 +38,12 @@ export function initAnalytics({ getState }) {
36 38
 
37 39
     _loadHandlers(analyticsScriptUrls, handlerConstructorOptions)
38 40
         .then(handlers => {
39
-            const permanentProperties = {
40
-                roomName: getState()['features/base/conference'].room,
41
+            const state = getState();
42
+            const permanentProperties: Object = {
43
+                roomName: state['features/base/conference'].room,
41 44
                 userAgent: navigator.userAgent
42 45
             };
43
-
44
-            const { group, server } = getState()['features/jwt'];
46
+            const { group, server } = state['features/jwt'];
45 47
 
46 48
             if (server) {
47 49
                 permanentProperties.server = server;
@@ -50,13 +52,14 @@ export function initAnalytics({ getState }) {
50 52
                 permanentProperties.group = group;
51 53
             }
52 54
 
53
-            // optionally include local deployment information based on
54
-            // the contents of window.config.deploymentInfo
55
-            if (config.deploymentInfo) {
56
-                for (const key in config.deploymentInfo) {
57
-                    if (config.deploymentInfo.hasOwnProperty(key)) {
58
-                        permanentProperties[key]
59
-                            = config.deploymentInfo[key];
55
+            // Optionally, include local deployment information based on the
56
+            // contents of window.config.deploymentInfo.
57
+            const { deploymentInfo } = config;
58
+
59
+            if (deploymentInfo) {
60
+                for (const key in deploymentInfo) {
61
+                    if (deploymentInfo.hasOwnProperty(key)) {
62
+                        permanentProperties[key] = deploymentInfo[key];
60 63
                     }
61 64
                 }
62 65
             }
@@ -113,23 +116,22 @@ function _loadHandlers(scriptURLs, handlerConstructorOptions) {
113 116
 
114 117
         if (analyticsHandlers.length === 0) {
115 118
             throw new Error('No analytics handlers available');
116
-        } else {
117
-            const handlers = [];
118
-
119
-            for (const Handler of analyticsHandlers) {
120
-                // catch any error while loading to avoid
121
-                // skipping analytics in case of multiple scripts
122
-                try {
123
-                    handlers.push(new Handler(handlerConstructorOptions));
124
-                } catch (error) {
125
-                    logger.warn(`Error creating analytics handler: ${error}`);
126
-                }
127
-            }
119
+        }
128 120
 
129
-            logger.debug(`Loaded ${handlers.length} analytics handlers`);
121
+        const handlers = [];
130 122
 
131
-            return handlers;
123
+        for (const Handler of analyticsHandlers) {
124
+            // Catch any error while loading to avoid skipping analytics in case
125
+            // of multiple scripts.
126
+            try {
127
+                handlers.push(new Handler(handlerConstructorOptions));
128
+            } catch (error) {
129
+                logger.warn(`Error creating analytics handler: ${error}`);
130
+            }
132 131
         }
132
+
133
+        logger.debug(`Loaded ${handlers.length} analytics handlers`);
134
+
135
+        return handlers;
133 136
     });
134 137
 }
135
-

+ 10
- 6
react/features/authentication/components/WaitForOwnerDialog.native.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import PropTypes from 'prop-types';
2 4
 import React, { Component } from 'react';
3 5
 import { Text } from 'react-native';
@@ -79,6 +81,8 @@ class WaitForOwnerDialog extends Component {
79 81
         );
80 82
     }
81 83
 
84
+    _onCancel: () => void;
85
+
82 86
     /**
83 87
      * Called when the cancel button is clicked.
84 88
      *
@@ -89,6 +93,8 @@ class WaitForOwnerDialog extends Component {
89 93
         this.props.dispatch(cancelWaitForOwner());
90 94
     }
91 95
 
96
+    _onLogin: () => void;
97
+
92 98
     /**
93 99
      * Called when the OK button is clicked.
94 100
      *
@@ -102,11 +108,11 @@ class WaitForOwnerDialog extends Component {
102 108
     /**
103 109
      * Renders a specific {@code string} which may contain HTML.
104 110
      *
105
-     * @param {string} html - The {@code string} which may contain HTML to
106
-     * render.
111
+     * @param {string|undefined} html - The {@code string} which may
112
+     * contain HTML to render.
107 113
      * @returns {ReactElement[]|string}
108 114
      */
109
-    _renderHTML(html) {
115
+    _renderHTML(html: ?string) {
110 116
         if (typeof html === 'string') {
111 117
             // At the time of this writing, the specified HTML contains a couple
112 118
             // of spaces one after the other. They do not cause a visible
@@ -164,9 +170,7 @@ class WaitForOwnerDialog extends Component {
164 170
  * }}
165 171
  */
166 172
 function _mapStateToProps(state) {
167
-    const {
168
-        authRequired
169
-    } = state['features/base/conference'];
173
+    const { authRequired } = state['features/base/conference'];
170 174
 
171 175
     return {
172 176
         _room: authRequired && authRequired.getName()

+ 6
- 3
react/features/authentication/middleware.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { appNavigate } from '../app';
2 4
 import {
3 5
     CONFERENCE_FAILED,
@@ -134,7 +136,8 @@ MiddlewareRegistry.register(store => next => action => {
134 136
  * @param {Object} store - The redux store.
135 137
  * @returns {void}
136 138
  */
137
-function _clearExistingWaitForOwnerTimeout({ getState }) {
139
+function _clearExistingWaitForOwnerTimeout(
140
+        { getState }: { getState: Function }) {
138 141
     const { waitForOwnerTimeoutID } = getState()['features/authentication'];
139 142
 
140 143
     waitForOwnerTimeoutID && clearTimeout(waitForOwnerTimeoutID);
@@ -146,7 +149,7 @@ function _clearExistingWaitForOwnerTimeout({ getState }) {
146 149
  * @param {Object} store - The redux store.
147 150
  * @returns {void}
148 151
  */
149
-function _hideLoginDialog({ dispatch }) {
152
+function _hideLoginDialog({ dispatch }: { dispatch: Dispatch<*> }) {
150 153
     dispatch(hideDialog(LoginDialog));
151 154
 }
152 155
 
@@ -156,6 +159,6 @@ function _hideLoginDialog({ dispatch }) {
156 159
  * @param {Object} store - The redux store.
157 160
  * @returns {boolean}
158 161
  */
159
-function _isWaitingForOwner({ getState }) {
162
+function _isWaitingForOwner({ getState }: { getState: Function }) {
160 163
     return Boolean(getState()['features/authentication'].waitForOwnerTimeoutID);
161 164
 }

+ 12
- 11
react/features/base/conference/middleware.js Ver arquivo

@@ -1,4 +1,5 @@
1
-/* global APP */
1
+// @flow
2
+
2 3
 import UIEvents from '../../../../service/UI/UIEvents';
3 4
 
4 5
 import { CONNECTION_ESTABLISHED } from '../connection';
@@ -34,6 +35,8 @@ import {
34 35
     _removeLocalTracksFromConference
35 36
 } from './functions';
36 37
 
38
+declare var APP: Object;
39
+
37 40
 /**
38 41
  * Implements the middleware of the feature base/conference.
39 42
  *
@@ -299,14 +302,12 @@ function _setLastN(store, next, action) {
299 302
  * @returns {Object} The new state that is the result of the reduction of the
300 303
  * specified action.
301 304
  */
302
-function _setReceiveVideoQuality(store, next, action) {
303
-    const { audioOnly, conference }
304
-        = store.getState()['features/base/conference'];
305
+function _setReceiveVideoQuality({ dispatch, getState }, next, action) {
306
+    const { audioOnly, conference } = getState()['features/base/conference'];
305 307
 
306 308
     conference.setReceiverVideoConstraint(action.receiveVideoQuality);
307
-
308 309
     if (audioOnly) {
309
-        store.dispatch(toggleAudioOnly());
310
+        dispatch(toggleAudioOnly());
310 311
     }
311 312
 
312 313
     return next(action);
@@ -321,9 +322,9 @@ function _setReceiveVideoQuality(store, next, action) {
321 322
  * @private
322 323
  * @returns {Promise}
323 324
  */
324
-function _syncConferenceLocalTracksWithState(store, action) {
325
-    const state = store.getState()['features/base/conference'];
326
-    const conference = state.conference;
325
+function _syncConferenceLocalTracksWithState({ getState }, action) {
326
+    const state = getState()['features/base/conference'];
327
+    const { conference } = state;
327 328
     let promise;
328 329
 
329 330
     // XXX The conference may already be in the process of being left, that's
@@ -354,8 +355,8 @@ function _syncConferenceLocalTracksWithState(store, action) {
354 355
  * @returns {Object} The new state that is the result of the reduction of the
355 356
  * specified action.
356 357
  */
357
-function _syncReceiveVideoQuality(store, next, action) {
358
-    const state = store.getState()['features/base/conference'];
358
+function _syncReceiveVideoQuality({ getState }, next, action) {
359
+    const state = getState()['features/base/conference'];
359 360
 
360 361
     state.conference.setReceiverVideoConstraint(state.receiveVideoQuality);
361 362
 

+ 3
- 1
react/features/base/conference/reducer.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { CONNECTION_WILL_CONNECT } from '../connection';
2 4
 import { JitsiConferenceErrors } from '../lib-jitsi-meet';
3 5
 import { assign, ReducerRegistry, set } from '../redux';
@@ -351,7 +353,7 @@ function _setReceiveVideoQuality(state, action) {
351 353
  * reduction of the specified action.
352 354
  */
353 355
 function _setRoom(state, action) {
354
-    let room = action.room;
356
+    let { room } = action;
355 357
 
356 358
     if (!isRoomValid(room)) {
357 359
         // Technically, there are multiple values which don't represent valid

+ 21
- 8
react/features/base/dialog/components/AbstractDialog.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import PropTypes from 'prop-types';
2 4
 import { Component } from 'react';
3 5
 
@@ -28,18 +30,21 @@ export default class AbstractDialog extends Component {
28 30
         dispatch: PropTypes.func
29 31
     };
30 32
 
33
+    _mounted: boolean;
34
+
35
+    state = {
36
+    };
37
+
31 38
     /**
32 39
      * Initializes a new {@code AbstractDialog} instance.
33 40
      *
34 41
      * @param {Object} props - The read-only React {@code Component} props with
35 42
      * which the new instance is to be initialized.
36 43
      */
37
-    constructor(props) {
44
+    constructor(props: Object) {
38 45
         super(props);
39 46
 
40
-        this.state = {
41
-        };
42
-
47
+        // Bind event handlers so they are only bound once per instance.
43 48
         this._onCancel = this._onCancel.bind(this);
44 49
         this._onSubmit = this._onSubmit.bind(this);
45 50
         this._onSubmitFulfilled = this._onSubmitFulfilled.bind(this);
@@ -66,6 +71,8 @@ export default class AbstractDialog extends Component {
66 71
         this._mounted = false;
67 72
     }
68 73
 
74
+    _onCancel: () => void;
75
+
69 76
     /**
70 77
      * Dispatches a redux action to hide this dialog when it's canceled.
71 78
      *
@@ -81,19 +88,21 @@ export default class AbstractDialog extends Component {
81 88
         }
82 89
     }
83 90
 
91
+    _onSubmit: (?string) => void;
92
+
84 93
     /**
85
-     * Submits this dialog. If the React {@code Component} prop
94
+     * Submits this {@code Dialog}. If the React {@code Component} prop
86 95
      * {@code onSubmit} is defined, the function that is the value of the prop
87 96
      * is invoked. If the function returns a {@code thenable}, then the
88 97
      * resolution of the {@code thenable} is awaited. If the submission
89 98
      * completes successfully, a redux action will be dispatched to hide this
90 99
      * dialog.
91 100
      *
92
-     * @private
93
-     * @param {string} value - The submitted value if any.
101
+     * @protected
102
+     * @param {string} [value] - The submitted value if any.
94 103
      * @returns {void}
95 104
      */
96
-    _onSubmit(value) {
105
+    _onSubmit(value: ?string) {
97 106
         const { okDisabled, onSubmit } = this.props;
98 107
 
99 108
         if (typeof okDisabled === 'undefined' || !okDisabled) {
@@ -125,6 +134,8 @@ export default class AbstractDialog extends Component {
125 134
         }
126 135
     }
127 136
 
137
+    _onSubmitFulfilled: () => void;
138
+
128 139
     /**
129 140
      * Notifies this {@code AbstractDialog} that it has been submitted
130 141
      * successfully. Dispatches a redux action to hide this dialog after it has
@@ -139,6 +150,8 @@ export default class AbstractDialog extends Component {
139 150
         this.props.dispatch(hideDialog());
140 151
     }
141 152
 
153
+    _onSubmitRejected: () => void;
154
+
142 155
     /**
143 156
      * Notifies this {@code AbstractDialog} that its submission has failed.
144 157
      *

+ 23
- 16
react/features/base/dialog/components/Dialog.native.js Ver arquivo

@@ -108,14 +108,9 @@ class Dialog extends AbstractDialog {
108 108
                 //   Secondly, we cannot get Prompt's default behavior anyway
109 109
                 //   because we've removed Prompt and we're preserving whatever
110 110
                 //   it's rendered only.
111
-                return (
112
-                    React.cloneElement(
113
-                        element,
114
-                        /* props */ {
115
-                            onRequestClose: this._onCancel
116
-                        },
117
-                        ...React.Children.toArray(element.props.children))
118
-                );
111
+                return this._cloneElement(element, /* props */ {
112
+                    onRequestClose: this._onCancel
113
+                });
119 114
             }
120 115
 
121 116
             if (type === TextInput) {
@@ -146,14 +141,9 @@ class Dialog extends AbstractDialog {
146 141
                         break;
147 142
                     }
148 143
 
149
-                    return (
150
-                        React.cloneElement(
151
-                            element,
152
-                            /* props */ {
153
-                                style: set(style, _TAG_KEY, undefined)
154
-                            },
155
-                            ...React.Children.toArray(element.props.children))
156
-                    );
144
+                    return this._cloneElement(element, /* props */ {
145
+                        style: set(style, _TAG_KEY, undefined)
146
+                    });
157 147
                 }
158 148
             }
159 149
 
@@ -163,6 +153,23 @@ class Dialog extends AbstractDialog {
163 153
         return element;
164 154
     }
165 155
 
156
+    /**
157
+     * Clones a specific {@code ReactElement} and adds/merges specific props
158
+     * into the clone.
159
+     *
160
+     * @param {ReactElement} element - The {@code ReactElement} to clone.
161
+     * @param {Object} props - The props to add/merge into the clone.
162
+     * @returns {ReactElement} The close of the specified {@code element} with
163
+     * the specified {@code props} added/merged.
164
+     */
165
+    _cloneElement(element, props) {
166
+        return (
167
+            React.cloneElement(
168
+                element,
169
+                props,
170
+                ...React.Children.toArray(element.props.children)));
171
+    }
172
+
166 173
     /**
167 174
      * Creates a deep clone of a specific {@code ReactElement} with the results
168 175
      * of calling a specific function on every node of a specific

+ 6
- 4
react/features/large-video/actions.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { _handleParticipantError } from '../base/conference';
2 4
 import { MEDIA_TYPE, VIDEO_TYPE } from '../base/media';
3 5
 import {
@@ -16,9 +18,9 @@ import {
16 18
  * @returns {Function}
17 19
  */
18 20
 export function selectParticipant() {
19
-    return (dispatch, getState) => {
21
+    return (dispatch: Dispatch<*>, getState: Function) => {
20 22
         const state = getState();
21
-        const conference = state['features/base/conference'].conference;
23
+        const { conference } = state['features/base/conference'];
22 24
 
23 25
         if (conference) {
24 26
             const largeVideo = state['features/large-video'];
@@ -51,7 +53,7 @@ export function selectParticipant() {
51 53
  * @returns {Function}
52 54
  */
53 55
 export function selectParticipantInLargeVideo() {
54
-    return (dispatch, getState) => {
56
+    return (dispatch: Dispatch<*>, getState: Function) => {
55 57
         const state = getState();
56 58
         const participantId = _electParticipantInLargeVideo(state);
57 59
         const largeVideo = state['features/large-video'];
@@ -76,7 +78,7 @@ export function selectParticipantInLargeVideo() {
76 78
  *     resolution: number
77 79
  * }}
78 80
  */
79
-export function updateKnownLargeVideoResolution(resolution) {
81
+export function updateKnownLargeVideoResolution(resolution: number) {
80 82
     return {
81 83
         type: UPDATE_KNOWN_LARGE_VIDEO_RESOLUTION,
82 84
         resolution

+ 6
- 5
react/features/mobile/external-api/middleware.js Ver arquivo

@@ -85,20 +85,21 @@ function _getSymbolDescription(symbol: Symbol) {
85 85
  * apps may listen to such events via the mechanisms provided by the (native)
86 86
  * mobile Jitsi Meet SDK.
87 87
  *
88
- * @param {Object} store - The redux store associated with the need to send the
89
- * specified event.
88
+ * @param {Object} store - The redux store.
90 89
  * @param {string} name - The name of the event to send.
91 90
  * @param {Object} data - The details/specifics of the event to send determined
92 91
  * by/associated with the specified {@code name}.
93 92
  * @private
94 93
  * @returns {void}
95 94
  */
96
-function _sendEvent(store: Object, name: string, data: Object) {
95
+function _sendEvent(
96
+        { getState }: { getState: Function },
97
+        name: string,
98
+        data: Object) {
97 99
     // The JavaScript App needs to provide uniquely identifying information
98 100
     // to the native ExternalAPI module so that the latter may match the former
99 101
     // to the native JitsiMeetView which hosts it.
100
-    const state = store.getState();
101
-    const { app } = state['features/app'];
102
+    const { app } = getState()['features/app'];
102 103
 
103 104
     if (app) {
104 105
         const { externalAPIScope } = app.props;

+ 7
- 3
react/features/overlay/reducer.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { CONFERENCE_FAILED } from '../base/conference';
2 4
 import {
3 5
     CONNECTION_ESTABLISHED,
@@ -140,10 +142,12 @@ function _connectionWillConnect(
140 142
  * @returns {Object} The new state of the feature overlay after the reduction of
141 143
  * the specified action.
142 144
  */
143
-function _mediaPermissionPromptVisibilityChanged(state, action) {
145
+function _mediaPermissionPromptVisibilityChanged(
146
+        state,
147
+        { browser, isVisible }) {
144 148
     return assign(state, {
145
-        browser: action.browser,
146
-        isMediaPermissionPromptVisible: action.isVisible
149
+        browser,
150
+        isMediaPermissionPromptVisible: isVisible
147 151
     });
148 152
 }
149 153
 

+ 11
- 12
react/features/room-lock/actions.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { setPassword } from '../base/conference';
2 4
 import { hideDialog, openDialog } from '../base/dialog';
3 5
 import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
@@ -9,15 +11,12 @@ import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
9 11
  * if specified or undefined if the current JitsiConference is to be locked.
10 12
  * @returns {Function}
11 13
  */
12
-export function beginRoomLockRequest(conference) {
13
-    return (dispatch, getState) => {
14
+export function beginRoomLockRequest(conference: ?Object) {
15
+    return (dispatch: Function, getState: Function) => {
14 16
         if (typeof conference === 'undefined') {
15
-            const state = getState();
16
-
17 17
             // eslint-disable-next-line no-param-reassign
18
-            conference = state['features/base/conference'].conference;
18
+            conference = getState()['features/base/conference'].conference;
19 19
         }
20
-
21 20
         if (conference) {
22 21
             dispatch(openDialog(RoomLockPrompt, { conference }));
23 22
         }
@@ -33,15 +32,15 @@ export function beginRoomLockRequest(conference) {
33 32
  * the specified conference.
34 33
  * @returns {Function}
35 34
  */
36
-export function endRoomLockRequest(conference, password) {
37
-    return dispatch => {
35
+export function endRoomLockRequest(
36
+        conference: { lock: Function },
37
+        password: ?string) {
38
+    return (dispatch: Function) => {
38 39
         const setPassword_
39 40
             = password
40 41
                 ? dispatch(setPassword(conference, conference.lock, password))
41 42
                 : Promise.resolve();
42
-        const endRoomLockRequest_ = () => {
43
-            dispatch(hideDialog());
44
-        };
43
+        const endRoomLockRequest_ = () => dispatch(hideDialog(RoomLockPrompt));
45 44
 
46 45
         setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
47 46
     };
@@ -59,6 +58,6 @@ export function endRoomLockRequest(conference, password) {
59 58
  *     props: PropTypes
60 59
  * }}
61 60
  */
62
-export function _showPasswordDialog(conference) {
61
+export function _openPasswordRequiredPrompt(conference: Object) {
63 62
     return openDialog(PasswordRequiredPrompt, { conference });
64 63
 }

+ 35
- 18
react/features/room-lock/components/PasswordRequiredPrompt.native.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import PropTypes from 'prop-types';
2 4
 import React, { Component } from 'react';
3 5
 import { connect } from 'react-redux';
@@ -6,35 +8,44 @@ import { setPassword } from '../../base/conference';
6 8
 import { Dialog } from '../../base/dialog';
7 9
 
8 10
 /**
9
- * Implements a React Component which prompts the user when a password is
10
- * required to join a conference.
11
+ * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
12
+ */
13
+type Props = {
14
+
15
+    /**
16
+     * The {@code JitsiConference} which requires a password.
17
+     *
18
+     * @type {JitsiConference}
19
+     */
20
+    conference: { join: Function },
21
+    dispatch: Dispatch<*>
22
+};
23
+
24
+/**
25
+ * Implements a React {@code Component} which prompts the user when a password
26
+ * is required to join a conference.
11 27
  */
12 28
 class PasswordRequiredPrompt extends Component {
13 29
     /**
14
-     * PasswordRequiredPrompt component's property types.
30
+     * {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
15 31
      *
16 32
      * @static
17 33
      */
18 34
     static propTypes = {
19
-        /**
20
-         * The JitsiConference which requires a password.
21
-         *
22
-         * @type {JitsiConference}
23
-         */
24 35
         conference: PropTypes.object,
25 36
         dispatch: PropTypes.func
26 37
     };
27 38
 
28 39
     /**
29
-     * Initializes a new PasswordRequiredPrompt instance.
40
+     * Initializes a new {@code PasswordRequiredPrompt} instance.
30 41
      *
31
-     * @param {Object} props - The read-only properties with which the new
32
-     * instance is to be initialized.
42
+     * @param {Props} props - The read-only React {@code Component} props with
43
+     * which the new instance is to be initialized.
33 44
      */
34
-    constructor(props) {
45
+    constructor(props: Props) {
35 46
         super(props);
36 47
 
37
-        // Bind event handlers so they are only bound once for every instance.
48
+        // Bind event handlers so they are only bound once per instance.
38 49
         this._onCancel = this._onCancel.bind(this);
39 50
         this._onSubmit = this._onSubmit.bind(this);
40 51
     }
@@ -55,11 +66,14 @@ class PasswordRequiredPrompt extends Component {
55 66
         );
56 67
     }
57 68
 
69
+    _onCancel: () => boolean;
70
+
58 71
     /**
59 72
      * Notifies this prompt that it has been dismissed by cancel.
60 73
      *
61 74
      * @private
62
-     * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
75
+     * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
76
+     * otherwise, {@code false}.
63 77
      */
64 78
     _onCancel() {
65 79
         // XXX The user has canceled this prompt for a password so we are to
@@ -69,16 +83,19 @@ class PasswordRequiredPrompt extends Component {
69 83
         return this._onSubmit(undefined);
70 84
     }
71 85
 
86
+    _onSubmit: (?string) => boolean;
87
+
72 88
     /**
73 89
      * Notifies this prompt that it has been dismissed by submitting a specific
74 90
      * value.
75 91
      *
76
-     * @param {string} value - The submitted value.
92
+     * @param {string|undefined} value - The submitted value.
77 93
      * @private
78
-     * @returns {boolean} True to hide this dialog/prompt; otherwise, false.
94
+     * @returns {boolean} If this prompt is to be closed/hidden, {@code true};
95
+     * otherwise, {@code false}.
79 96
      */
80
-    _onSubmit(value) {
81
-        const conference = this.props.conference;
97
+    _onSubmit(value: ?string) {
98
+        const { conference }: { conference: { join: Function } } = this.props;
82 99
 
83 100
         this.props.dispatch(setPassword(conference, conference.join, value));
84 101
 

+ 17
- 9
react/features/room-lock/components/PasswordRequiredPrompt.web.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import AKFieldText from '@atlaskit/field-text';
2 4
 import PropTypes from 'prop-types';
3 5
 import React, { Component } from 'react';
@@ -28,6 +30,10 @@ class PasswordRequiredPrompt extends Component {
28 30
         t: PropTypes.func
29 31
     };
30 32
 
33
+    state = {
34
+        password: ''
35
+    };
36
+
31 37
     /**
32 38
      * Initializes a new PasswordRequiredPrompt instance.
33 39
      *
@@ -37,10 +43,7 @@ class PasswordRequiredPrompt extends Component {
37 43
     constructor(props) {
38 44
         super(props);
39 45
 
40
-        this.state = {
41
-            password: ''
42
-        };
43
-
46
+        // Bind event handlers so they are only bound once per instance.
44 47
         this._onPasswordChanged = this._onPasswordChanged.bind(this);
45 48
         this._onSubmit = this._onSubmit.bind(this);
46 49
     }
@@ -59,7 +62,8 @@ class PasswordRequiredPrompt extends Component {
59 62
                 titleKey = 'dialog.passwordRequired'
60 63
                 width = 'small'>
61 64
                 { this._renderBody() }
62
-            </Dialog>);
65
+            </Dialog>
66
+        );
63 67
     }
64 68
 
65 69
     /**
@@ -84,6 +88,8 @@ class PasswordRequiredPrompt extends Component {
84 88
         );
85 89
     }
86 90
 
91
+    _onPasswordChanged: ({ target: { value: * }}) => void;
92
+
87 93
     /**
88 94
      * Notifies this dialog that password has changed.
89 95
      *
@@ -91,17 +97,19 @@ class PasswordRequiredPrompt extends Component {
91 97
      * @private
92 98
      * @returns {void}
93 99
      */
94
-    _onPasswordChanged(event) {
100
+    _onPasswordChanged({ target: { value } }) {
95 101
         this.setState({
96
-            password: event.target.value
102
+            password: value
97 103
         });
98 104
     }
99 105
 
106
+    _onSubmit: () => boolean;
107
+
100 108
     /**
101
-     * Dispatches action to submit value from thus dialog.
109
+     * Dispatches action to submit value from this dialog.
102 110
      *
103 111
      * @private
104
-     * @returns {void}
112
+     * @returns {boolean}
105 113
      */
106 114
     _onSubmit() {
107 115
         const { conference } = this.props;

+ 10
- 4
react/features/room-lock/components/RoomLockPrompt.native.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import PropTypes from 'prop-types';
2 4
 import React, { Component } from 'react';
3 5
 import { connect } from 'react-redux';
@@ -29,13 +31,13 @@ class RoomLockPrompt extends Component {
29 31
     /**
30 32
      * Initializes a new RoomLockPrompt instance.
31 33
      *
32
-     * @param {Object} props - The read-only properties with which the new
34
+     * @param {Props} props - The read-only properties with which the new
33 35
      * instance is to be initialized.
34 36
      */
35 37
     constructor(props) {
36 38
         super(props);
37 39
 
38
-        // Bind event handlers so they are only bound once for every instance.
40
+        // Bind event handlers so they are only bound once per instance.
39 41
         this._onCancel = this._onCancel.bind(this);
40 42
         this._onSubmit = this._onSubmit.bind(this);
41 43
     }
@@ -56,6 +58,8 @@ class RoomLockPrompt extends Component {
56 58
         );
57 59
     }
58 60
 
61
+    _onCancel: () => boolean;
62
+
59 63
     /**
60 64
      * Notifies this prompt that it has been dismissed by cancel.
61 65
      *
@@ -68,17 +72,19 @@ class RoomLockPrompt extends Component {
68 72
         return this._onSubmit(undefined);
69 73
     }
70 74
 
75
+    _onSubmit: (?string) => boolean;
76
+
71 77
     /**
72 78
      * Notifies this prompt that it has been dismissed by submitting a specific
73 79
      * value.
74 80
      *
75
-     * @param {string} value - The submitted value.
81
+     * @param {string|undefined} value - The submitted value.
76 82
      * @private
77 83
      * @returns {boolean} False because we do not want to hide this
78 84
      * dialog/prompt as the hiding will be handled inside endRoomLockRequest
79 85
      * after setting the password is resolved.
80 86
      */
81
-    _onSubmit(value) {
87
+    _onSubmit(value: ?string) {
82 88
         this.props.dispatch(endRoomLockRequest(this.props.conference, value));
83 89
 
84 90
         return false; // Do not hide.

+ 1
- 1
react/features/room-lock/components/index.js Ver arquivo

@@ -1,2 +1,2 @@
1
-export { default as RoomLockPrompt } from './RoomLockPrompt';
2 1
 export { default as PasswordRequiredPrompt } from './PasswordRequiredPrompt';
2
+export { default as RoomLockPrompt } from './RoomLockPrompt';

+ 6
- 5
react/features/room-lock/middleware.js Ver arquivo

@@ -1,6 +1,4 @@
1
-/* global APP */
2
-
3
-import UIEvents from '../../../service/UI/UIEvents';
1
+// @flow
4 2
 
5 3
 import {
6 4
     CONFERENCE_FAILED,
@@ -9,8 +7,11 @@ import {
9 7
 } from '../base/conference';
10 8
 import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
11 9
 import { MiddlewareRegistry } from '../base/redux';
10
+import UIEvents from '../../../service/UI/UIEvents';
11
+
12
+import { _openPasswordRequiredPrompt } from './actions';
12 13
 
13
-import { _showPasswordDialog } from './actions';
14
+declare var APP: Object;
14 15
 
15 16
 const logger = require('jitsi-meet-logger').getLogger(__filename);
16 17
 
@@ -27,7 +28,7 @@ MiddlewareRegistry.register(store => next => action => {
27 28
         const { conference, error } = action;
28 29
 
29 30
         if (conference && error === JitsiConferenceErrors.PASSWORD_REQUIRED) {
30
-            store.dispatch(_showPasswordDialog(conference));
31
+            store.dispatch(_openPasswordRequiredPrompt(conference));
31 32
         }
32 33
         break;
33 34
     }

+ 9
- 8
react/features/unsupported-browser/middleware.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { appNavigate } from '../app';
2 4
 import { SET_WEBRTC_READY } from '../base/lib-jitsi-meet';
3 5
 import { MiddlewareRegistry } from '../base/redux';
@@ -28,26 +30,25 @@ MiddlewareRegistry.register(store => next => action => {
28 30
  * specified action to the specified store.
29 31
  * @param {Action} action - The Redux action SET_WEBRTC_READY which is being
30 32
  * dispatched in the specified store.
33
+ * @private
31 34
  * @returns {Object} The new state that is the result of the reduction of the
32 35
  * specified action.
33
- * @private
34 36
  */
35
-function _setWebRTCReady(store, next, action) {
36
-    const nextState = next(action);
37
+function _setWebRTCReady({ dispatch, getState }, next, action) {
38
+    const result = next(action);
37 39
 
38 40
     // FIXME The feature unsupported-browser needs to notify the app that it may
39 41
     // need to render a different Component at its current location because the
40 42
     // execution enviroment has changed. The current location is not necessarily
41 43
     // available through window.location (e.g. on mobile) but the following
42 44
     // works at the time of this writing.
43
-    const windowLocation
44
-        = store.getState()['features/app'].app.getWindowLocation();
45
+    const windowLocation = getState()['features/app'].app.getWindowLocation();
45 46
 
46 47
     if (windowLocation) {
47
-        const href = windowLocation.href;
48
+        const { href } = windowLocation;
48 49
 
49
-        href && store.dispatch(appNavigate(href));
50
+        href && dispatch(appNavigate(href));
50 51
     }
51 52
 
52
-    return nextState;
53
+    return result;
53 54
 }

+ 52
- 35
react/features/welcome/components/AbstractWelcomePage.js Ver arquivo

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import PropTypes from 'prop-types';
2 4
 import { Component } from 'react';
3 5
 
@@ -6,6 +8,14 @@ import { isRoomValid } from '../../base/conference';
6 8
 
7 9
 import { generateRoomWithoutSeparator } from '../functions';
8 10
 
11
+/**
12
+ * {@code AbstractWelcomePage}'s React {@code Component} prop types.
13
+ */
14
+type Props = {
15
+    _room: string,
16
+    dispatch: Dispatch<*>
17
+};
18
+
9 19
 /**
10 20
  * Base (abstract) class for container component rendering the welcome page.
11 21
  *
@@ -22,38 +32,39 @@ export class AbstractWelcomePage extends Component {
22 32
         dispatch: PropTypes.func
23 33
     };
24 34
 
35
+    _mounted: ?boolean;
36
+
37
+    /**
38
+     * Save room name into component's local state.
39
+     *
40
+     * @type {Object}
41
+     * @property {number|null} animateTimeoutId - Identifier of the letter
42
+     * animation timeout.
43
+     * @property {string} generatedRoomname - Automatically generated room name.
44
+     * @property {string} room - Room name.
45
+     * @property {string} roomPlaceholder - Room placeholder that's used as a
46
+     * placeholder for input.
47
+     * @property {nubmer|null} updateTimeoutId - Identifier of the timeout
48
+     * updating the generated room name.
49
+     */
50
+    state = {
51
+        animateTimeoutId: undefined,
52
+        generatedRoomname: '',
53
+        joining: false,
54
+        room: '',
55
+        roomPlaceholder: '',
56
+        updateTimeoutId: undefined
57
+    };
58
+
25 59
     /**
26 60
      * Initializes a new {@code AbstractWelcomePage} instance.
27 61
      *
28
-     * @param {Object} props - The React {@code Component} props to initialize
62
+     * @param {Props} props - The React {@code Component} props to initialize
29 63
      * the new {@code AbstractWelcomePage} instance with.
30 64
      */
31
-    constructor(props) {
65
+    constructor(props: Props) {
32 66
         super(props);
33 67
 
34
-        /**
35
-         * Save room name into component's local state.
36
-         *
37
-         * @type {Object}
38
-         * @property {number|null} animateTimeoutId - Identifier of the letter
39
-         * animation timeout.
40
-         * @property {string} generatedRoomname - Automatically generated
41
-         * room name.
42
-         * @property {string} room - Room name.
43
-         * @property {string} roomPlaceholder - Room placeholder
44
-         * that's used as a placeholder for input.
45
-         * @property {nubmer|null} updateTimeoutId - Identifier of the timeout
46
-         * updating the generated room name.
47
-         */
48
-        this.state = {
49
-            animateTimeoutId: null,
50
-            generatedRoomname: '',
51
-            joining: false,
52
-            room: '',
53
-            roomPlaceholder: '',
54
-            updateTimeoutId: null
55
-        };
56
-
57 68
         // Bind event handlers so they are only bound once per instance.
58 69
         this._animateRoomnameChanging
59 70
             = this._animateRoomnameChanging.bind(this);
@@ -77,9 +88,9 @@ export class AbstractWelcomePage extends Component {
77 88
      * before this mounted component receives new props.
78 89
      *
79 90
      * @inheritdoc
80
-     * @param {Object} nextProps - New props component will receive.
91
+     * @param {Props} nextProps - New props component will receive.
81 92
      */
82
-    componentWillReceiveProps(nextProps) {
93
+    componentWillReceiveProps(nextProps: Props) {
83 94
         this.setState({ room: nextProps._room });
84 95
     }
85 96
 
@@ -94,6 +105,8 @@ export class AbstractWelcomePage extends Component {
94 105
         this._mounted = false;
95 106
     }
96 107
 
108
+    _animateRoomnameChanging: (string) => void;
109
+
97 110
     /**
98 111
      * Animates the changing of the room name.
99 112
      *
@@ -102,8 +115,8 @@ export class AbstractWelcomePage extends Component {
102 115
      * @private
103 116
      * @returns {void}
104 117
      */
105
-    _animateRoomnameChanging(word) {
106
-        let animateTimeoutId = null;
118
+    _animateRoomnameChanging(word: string) {
119
+        let animateTimeoutId;
107 120
         const roomPlaceholder = this.state.roomPlaceholder + word.substr(0, 1);
108 121
 
109 122
         if (word.length > 1) {
@@ -115,7 +128,6 @@ export class AbstractWelcomePage extends Component {
115 128
                     },
116 129
                     70);
117 130
         }
118
-
119 131
         this.setState({
120 132
             animateTimeoutId,
121 133
             roomPlaceholder
@@ -145,6 +157,8 @@ export class AbstractWelcomePage extends Component {
145 157
         return this.state.joining || !isRoomValid(this.state.room);
146 158
     }
147 159
 
160
+    _onJoin: () => void;
161
+
148 162
     /**
149 163
      * Handles joining. Either by clicking on 'Join' button
150 164
      * or by pressing 'Enter' in room name input field.
@@ -160,15 +174,16 @@ export class AbstractWelcomePage extends Component {
160 174
 
161 175
             // By the time the Promise of appNavigate settles, this component
162 176
             // may have already been unmounted.
163
-            const onAppNavigateSettled = () => {
164
-                this._mounted && this.setState({ joining: false });
165
-            };
177
+            const onAppNavigateSettled
178
+                = () => this._mounted && this.setState({ joining: false });
166 179
 
167 180
             this.props.dispatch(appNavigate(room))
168 181
                 .then(onAppNavigateSettled, onAppNavigateSettled);
169 182
         }
170 183
     }
171 184
 
185
+    _onRoomChange: (string) => void;
186
+
172 187
     /**
173 188
      * Handles 'change' event for the room name text input field.
174 189
      *
@@ -177,10 +192,12 @@ export class AbstractWelcomePage extends Component {
177 192
      * @protected
178 193
      * @returns {void}
179 194
      */
180
-    _onRoomChange(value) {
195
+    _onRoomChange(value: string) {
181 196
         this.setState({ room: value });
182 197
     }
183 198
 
199
+    _updateRoomname: () => void;
200
+
184 201
     /**
185 202
      * Triggers the generation of a new room name and initiates an animation of
186 203
      * its changing.
@@ -214,7 +231,7 @@ export class AbstractWelcomePage extends Component {
214 231
  *     _room: string
215 232
  * }}
216 233
  */
217
-export function _mapStateToProps(state) {
234
+export function _mapStateToProps(state: Object) {
218 235
     return {
219 236
         _room: state['features/base/conference'].room
220 237
     };

Carregando…
Cancelar
Salvar