ソースを参照

Flow, coding style

j8
Lyubo Marinov 8年前
コミット
f53c79ab24

+ 29
- 27
react/features/analytics/functions.js ファイルの表示

1
+// @flow
2
+
1
 import JitsiMeetJS, { isAnalyticsEnabled } from '../base/lib-jitsi-meet';
3
 import JitsiMeetJS, { isAnalyticsEnabled } from '../base/lib-jitsi-meet';
2
 import { getJitsiMeetGlobalNS, loadScript } from '../base/util';
4
 import { getJitsiMeetGlobalNS, loadScript } from '../base/util';
3
 
5
 
13
  * is being dispatched.
15
  * is being dispatched.
14
  * @returns {void}
16
  * @returns {void}
15
  */
17
  */
16
-export function initAnalytics({ getState }) {
18
+export function initAnalytics({ getState }: { getState: Function }) {
17
     getJitsiMeetGlobalNS().analyticsHandlers = [];
19
     getJitsiMeetGlobalNS().analyticsHandlers = [];
18
     window.analyticsHandlers = []; // Legacy support.
20
     window.analyticsHandlers = []; // Legacy support.
19
 
21
 
36
 
38
 
37
     _loadHandlers(analyticsScriptUrls, handlerConstructorOptions)
39
     _loadHandlers(analyticsScriptUrls, handlerConstructorOptions)
38
         .then(handlers => {
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
                 userAgent: navigator.userAgent
44
                 userAgent: navigator.userAgent
42
             };
45
             };
43
-
44
-            const { group, server } = getState()['features/jwt'];
46
+            const { group, server } = state['features/jwt'];
45
 
47
 
46
             if (server) {
48
             if (server) {
47
                 permanentProperties.server = server;
49
                 permanentProperties.server = server;
50
                 permanentProperties.group = group;
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
 
116
 
114
         if (analyticsHandlers.length === 0) {
117
         if (analyticsHandlers.length === 0) {
115
             throw new Error('No analytics handlers available');
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 ファイルの表示

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

+ 6
- 3
react/features/authentication/middleware.js ファイルの表示

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

+ 12
- 11
react/features/base/conference/middleware.js ファイルの表示

1
-/* global APP */
1
+// @flow
2
+
2
 import UIEvents from '../../../../service/UI/UIEvents';
3
 import UIEvents from '../../../../service/UI/UIEvents';
3
 
4
 
4
 import { CONNECTION_ESTABLISHED } from '../connection';
5
 import { CONNECTION_ESTABLISHED } from '../connection';
34
     _removeLocalTracksFromConference
35
     _removeLocalTracksFromConference
35
 } from './functions';
36
 } from './functions';
36
 
37
 
38
+declare var APP: Object;
39
+
37
 /**
40
 /**
38
  * Implements the middleware of the feature base/conference.
41
  * Implements the middleware of the feature base/conference.
39
  *
42
  *
299
  * @returns {Object} The new state that is the result of the reduction of the
302
  * @returns {Object} The new state that is the result of the reduction of the
300
  * specified action.
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
     conference.setReceiverVideoConstraint(action.receiveVideoQuality);
308
     conference.setReceiverVideoConstraint(action.receiveVideoQuality);
307
-
308
     if (audioOnly) {
309
     if (audioOnly) {
309
-        store.dispatch(toggleAudioOnly());
310
+        dispatch(toggleAudioOnly());
310
     }
311
     }
311
 
312
 
312
     return next(action);
313
     return next(action);
321
  * @private
322
  * @private
322
  * @returns {Promise}
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
     let promise;
328
     let promise;
328
 
329
 
329
     // XXX The conference may already be in the process of being left, that's
330
     // XXX The conference may already be in the process of being left, that's
354
  * @returns {Object} The new state that is the result of the reduction of the
355
  * @returns {Object} The new state that is the result of the reduction of the
355
  * specified action.
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
     state.conference.setReceiverVideoConstraint(state.receiveVideoQuality);
361
     state.conference.setReceiverVideoConstraint(state.receiveVideoQuality);
361
 
362
 

+ 3
- 1
react/features/base/conference/reducer.js ファイルの表示

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

+ 21
- 8
react/features/base/dialog/components/AbstractDialog.js ファイルの表示

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

+ 23
- 16
react/features/base/dialog/components/Dialog.native.js ファイルの表示

108
                 //   Secondly, we cannot get Prompt's default behavior anyway
108
                 //   Secondly, we cannot get Prompt's default behavior anyway
109
                 //   because we've removed Prompt and we're preserving whatever
109
                 //   because we've removed Prompt and we're preserving whatever
110
                 //   it's rendered only.
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
             if (type === TextInput) {
116
             if (type === TextInput) {
146
                         break;
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
         return element;
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
      * Creates a deep clone of a specific {@code ReactElement} with the results
174
      * Creates a deep clone of a specific {@code ReactElement} with the results
168
      * of calling a specific function on every node of a specific
175
      * of calling a specific function on every node of a specific

+ 6
- 4
react/features/large-video/actions.js ファイルの表示

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

+ 6
- 5
react/features/mobile/external-api/middleware.js ファイルの表示

85
  * apps may listen to such events via the mechanisms provided by the (native)
85
  * apps may listen to such events via the mechanisms provided by the (native)
86
  * mobile Jitsi Meet SDK.
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
  * @param {string} name - The name of the event to send.
89
  * @param {string} name - The name of the event to send.
91
  * @param {Object} data - The details/specifics of the event to send determined
90
  * @param {Object} data - The details/specifics of the event to send determined
92
  * by/associated with the specified {@code name}.
91
  * by/associated with the specified {@code name}.
93
  * @private
92
  * @private
94
  * @returns {void}
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
     // The JavaScript App needs to provide uniquely identifying information
99
     // The JavaScript App needs to provide uniquely identifying information
98
     // to the native ExternalAPI module so that the latter may match the former
100
     // to the native ExternalAPI module so that the latter may match the former
99
     // to the native JitsiMeetView which hosts it.
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
     if (app) {
104
     if (app) {
104
         const { externalAPIScope } = app.props;
105
         const { externalAPIScope } = app.props;

+ 7
- 3
react/features/overlay/reducer.js ファイルの表示

1
+// @flow
2
+
1
 import { CONFERENCE_FAILED } from '../base/conference';
3
 import { CONFERENCE_FAILED } from '../base/conference';
2
 import {
4
 import {
3
     CONNECTION_ESTABLISHED,
5
     CONNECTION_ESTABLISHED,
140
  * @returns {Object} The new state of the feature overlay after the reduction of
142
  * @returns {Object} The new state of the feature overlay after the reduction of
141
  * the specified action.
143
  * the specified action.
142
  */
144
  */
143
-function _mediaPermissionPromptVisibilityChanged(state, action) {
145
+function _mediaPermissionPromptVisibilityChanged(
146
+        state,
147
+        { browser, isVisible }) {
144
     return assign(state, {
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 ファイルの表示

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

+ 35
- 18
react/features/room-lock/components/PasswordRequiredPrompt.native.js ファイルの表示

1
+// @flow
2
+
1
 import PropTypes from 'prop-types';
3
 import PropTypes from 'prop-types';
2
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
3
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
6
 import { Dialog } from '../../base/dialog';
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
 class PasswordRequiredPrompt extends Component {
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
      * @static
32
      * @static
17
      */
33
      */
18
     static propTypes = {
34
     static propTypes = {
19
-        /**
20
-         * The JitsiConference which requires a password.
21
-         *
22
-         * @type {JitsiConference}
23
-         */
24
         conference: PropTypes.object,
35
         conference: PropTypes.object,
25
         dispatch: PropTypes.func
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
         super(props);
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
         this._onCancel = this._onCancel.bind(this);
49
         this._onCancel = this._onCancel.bind(this);
39
         this._onSubmit = this._onSubmit.bind(this);
50
         this._onSubmit = this._onSubmit.bind(this);
40
     }
51
     }
55
         );
66
         );
56
     }
67
     }
57
 
68
 
69
+    _onCancel: () => boolean;
70
+
58
     /**
71
     /**
59
      * Notifies this prompt that it has been dismissed by cancel.
72
      * Notifies this prompt that it has been dismissed by cancel.
60
      *
73
      *
61
      * @private
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
     _onCancel() {
78
     _onCancel() {
65
         // XXX The user has canceled this prompt for a password so we are to
79
         // XXX The user has canceled this prompt for a password so we are to
69
         return this._onSubmit(undefined);
83
         return this._onSubmit(undefined);
70
     }
84
     }
71
 
85
 
86
+    _onSubmit: (?string) => boolean;
87
+
72
     /**
88
     /**
73
      * Notifies this prompt that it has been dismissed by submitting a specific
89
      * Notifies this prompt that it has been dismissed by submitting a specific
74
      * value.
90
      * value.
75
      *
91
      *
76
-     * @param {string} value - The submitted value.
92
+     * @param {string|undefined} value - The submitted value.
77
      * @private
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
         this.props.dispatch(setPassword(conference, conference.join, value));
100
         this.props.dispatch(setPassword(conference, conference.join, value));
84
 
101
 

+ 17
- 9
react/features/room-lock/components/PasswordRequiredPrompt.web.js ファイルの表示

1
+// @flow
2
+
1
 import AKFieldText from '@atlaskit/field-text';
3
 import AKFieldText from '@atlaskit/field-text';
2
 import PropTypes from 'prop-types';
4
 import PropTypes from 'prop-types';
3
 import React, { Component } from 'react';
5
 import React, { Component } from 'react';
28
         t: PropTypes.func
30
         t: PropTypes.func
29
     };
31
     };
30
 
32
 
33
+    state = {
34
+        password: ''
35
+    };
36
+
31
     /**
37
     /**
32
      * Initializes a new PasswordRequiredPrompt instance.
38
      * Initializes a new PasswordRequiredPrompt instance.
33
      *
39
      *
37
     constructor(props) {
43
     constructor(props) {
38
         super(props);
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
         this._onPasswordChanged = this._onPasswordChanged.bind(this);
47
         this._onPasswordChanged = this._onPasswordChanged.bind(this);
45
         this._onSubmit = this._onSubmit.bind(this);
48
         this._onSubmit = this._onSubmit.bind(this);
46
     }
49
     }
59
                 titleKey = 'dialog.passwordRequired'
62
                 titleKey = 'dialog.passwordRequired'
60
                 width = 'small'>
63
                 width = 'small'>
61
                 { this._renderBody() }
64
                 { this._renderBody() }
62
-            </Dialog>);
65
+            </Dialog>
66
+        );
63
     }
67
     }
64
 
68
 
65
     /**
69
     /**
84
         );
88
         );
85
     }
89
     }
86
 
90
 
91
+    _onPasswordChanged: ({ target: { value: * }}) => void;
92
+
87
     /**
93
     /**
88
      * Notifies this dialog that password has changed.
94
      * Notifies this dialog that password has changed.
89
      *
95
      *
91
      * @private
97
      * @private
92
      * @returns {void}
98
      * @returns {void}
93
      */
99
      */
94
-    _onPasswordChanged(event) {
100
+    _onPasswordChanged({ target: { value } }) {
95
         this.setState({
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
      * @private
111
      * @private
104
-     * @returns {void}
112
+     * @returns {boolean}
105
      */
113
      */
106
     _onSubmit() {
114
     _onSubmit() {
107
         const { conference } = this.props;
115
         const { conference } = this.props;

+ 10
- 4
react/features/room-lock/components/RoomLockPrompt.native.js ファイルの表示

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

+ 1
- 1
react/features/room-lock/components/index.js ファイルの表示

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

+ 6
- 5
react/features/room-lock/middleware.js ファイルの表示

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

+ 9
- 8
react/features/unsupported-browser/middleware.js ファイルの表示

1
+// @flow
2
+
1
 import { appNavigate } from '../app';
3
 import { appNavigate } from '../app';
2
 import { SET_WEBRTC_READY } from '../base/lib-jitsi-meet';
4
 import { SET_WEBRTC_READY } from '../base/lib-jitsi-meet';
3
 import { MiddlewareRegistry } from '../base/redux';
5
 import { MiddlewareRegistry } from '../base/redux';
28
  * specified action to the specified store.
30
  * specified action to the specified store.
29
  * @param {Action} action - The Redux action SET_WEBRTC_READY which is being
31
  * @param {Action} action - The Redux action SET_WEBRTC_READY which is being
30
  * dispatched in the specified store.
32
  * dispatched in the specified store.
33
+ * @private
31
  * @returns {Object} The new state that is the result of the reduction of the
34
  * @returns {Object} The new state that is the result of the reduction of the
32
  * specified action.
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
     // FIXME The feature unsupported-browser needs to notify the app that it may
40
     // FIXME The feature unsupported-browser needs to notify the app that it may
39
     // need to render a different Component at its current location because the
41
     // need to render a different Component at its current location because the
40
     // execution enviroment has changed. The current location is not necessarily
42
     // execution enviroment has changed. The current location is not necessarily
41
     // available through window.location (e.g. on mobile) but the following
43
     // available through window.location (e.g. on mobile) but the following
42
     // works at the time of this writing.
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
     if (windowLocation) {
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 ファイルの表示

1
+// @flow
2
+
1
 import PropTypes from 'prop-types';
3
 import PropTypes from 'prop-types';
2
 import { Component } from 'react';
4
 import { Component } from 'react';
3
 
5
 
6
 
8
 
7
 import { generateRoomWithoutSeparator } from '../functions';
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
  * Base (abstract) class for container component rendering the welcome page.
20
  * Base (abstract) class for container component rendering the welcome page.
11
  *
21
  *
22
         dispatch: PropTypes.func
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
      * Initializes a new {@code AbstractWelcomePage} instance.
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
      * the new {@code AbstractWelcomePage} instance with.
63
      * the new {@code AbstractWelcomePage} instance with.
30
      */
64
      */
31
-    constructor(props) {
65
+    constructor(props: Props) {
32
         super(props);
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
         // Bind event handlers so they are only bound once per instance.
68
         // Bind event handlers so they are only bound once per instance.
58
         this._animateRoomnameChanging
69
         this._animateRoomnameChanging
59
             = this._animateRoomnameChanging.bind(this);
70
             = this._animateRoomnameChanging.bind(this);
77
      * before this mounted component receives new props.
88
      * before this mounted component receives new props.
78
      *
89
      *
79
      * @inheritdoc
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
         this.setState({ room: nextProps._room });
94
         this.setState({ room: nextProps._room });
84
     }
95
     }
85
 
96
 
94
         this._mounted = false;
105
         this._mounted = false;
95
     }
106
     }
96
 
107
 
108
+    _animateRoomnameChanging: (string) => void;
109
+
97
     /**
110
     /**
98
      * Animates the changing of the room name.
111
      * Animates the changing of the room name.
99
      *
112
      *
102
      * @private
115
      * @private
103
      * @returns {void}
116
      * @returns {void}
104
      */
117
      */
105
-    _animateRoomnameChanging(word) {
106
-        let animateTimeoutId = null;
118
+    _animateRoomnameChanging(word: string) {
119
+        let animateTimeoutId;
107
         const roomPlaceholder = this.state.roomPlaceholder + word.substr(0, 1);
120
         const roomPlaceholder = this.state.roomPlaceholder + word.substr(0, 1);
108
 
121
 
109
         if (word.length > 1) {
122
         if (word.length > 1) {
115
                     },
128
                     },
116
                     70);
129
                     70);
117
         }
130
         }
118
-
119
         this.setState({
131
         this.setState({
120
             animateTimeoutId,
132
             animateTimeoutId,
121
             roomPlaceholder
133
             roomPlaceholder
145
         return this.state.joining || !isRoomValid(this.state.room);
157
         return this.state.joining || !isRoomValid(this.state.room);
146
     }
158
     }
147
 
159
 
160
+    _onJoin: () => void;
161
+
148
     /**
162
     /**
149
      * Handles joining. Either by clicking on 'Join' button
163
      * Handles joining. Either by clicking on 'Join' button
150
      * or by pressing 'Enter' in room name input field.
164
      * or by pressing 'Enter' in room name input field.
160
 
174
 
161
             // By the time the Promise of appNavigate settles, this component
175
             // By the time the Promise of appNavigate settles, this component
162
             // may have already been unmounted.
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
             this.props.dispatch(appNavigate(room))
180
             this.props.dispatch(appNavigate(room))
168
                 .then(onAppNavigateSettled, onAppNavigateSettled);
181
                 .then(onAppNavigateSettled, onAppNavigateSettled);
169
         }
182
         }
170
     }
183
     }
171
 
184
 
185
+    _onRoomChange: (string) => void;
186
+
172
     /**
187
     /**
173
      * Handles 'change' event for the room name text input field.
188
      * Handles 'change' event for the room name text input field.
174
      *
189
      *
177
      * @protected
192
      * @protected
178
      * @returns {void}
193
      * @returns {void}
179
      */
194
      */
180
-    _onRoomChange(value) {
195
+    _onRoomChange(value: string) {
181
         this.setState({ room: value });
196
         this.setState({ room: value });
182
     }
197
     }
183
 
198
 
199
+    _updateRoomname: () => void;
200
+
184
     /**
201
     /**
185
      * Triggers the generation of a new room name and initiates an animation of
202
      * Triggers the generation of a new room name and initiates an animation of
186
      * its changing.
203
      * its changing.
214
  *     _room: string
231
  *     _room: string
215
  * }}
232
  * }}
216
  */
233
  */
217
-export function _mapStateToProps(state) {
234
+export function _mapStateToProps(state: Object) {
218
     return {
235
     return {
219
         _room: state['features/base/conference'].room
236
         _room: state['features/base/conference'].room
220
     };
237
     };

読み込み中…
キャンセル
保存