Kaynağa Gözat

Partially prepare for eslint-plugin-flowtype 2.37.0

master
Lyubo Marinov 7 yıl önce
ebeveyn
işleme
5561a9c031

+ 6
- 1
modules/API/API.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
2 4
 import { parseJWTFromURLParams } from '../../react/features/jwt';
3 5
 import { getJitsiMeetTransport } from '../transport';
@@ -207,7 +209,10 @@ class API {
207 209
      * @param {Object} options - Object with the message properties.
208 210
      * @returns {void}
209 211
      */
210
-    notifyReceivedChatMessage({ body, id, nick, ts } = {}) {
212
+    notifyReceivedChatMessage(
213
+            { body, id, nick, ts }: {
214
+                body: *, id: string, nick: string, ts: *
215
+            } = {}) {
211 216
         if (APP.conference.isLocalId(id)) {
212 217
             return;
213 218
         }

+ 16
- 11
react/features/base/conference/actions.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2 4
 import { setAudioMuted, setVideoMuted } from '../media';
3 5
 import {
@@ -161,7 +163,7 @@ function _setLocalParticipantData(conference, state) {
161 163
  * }}
162 164
  * @public
163 165
  */
164
-export function conferenceFailed(conference, error) {
166
+export function conferenceFailed(conference: Object, error: string) {
165 167
     return {
166 168
         type: CONFERENCE_FAILED,
167 169
         conference,
@@ -179,7 +181,7 @@ export function conferenceFailed(conference, error) {
179 181
  *     conference: JitsiConference
180 182
  * }}
181 183
  */
182
-export function conferenceJoined(conference) {
184
+export function conferenceJoined(conference: Object) {
183 185
     return {
184 186
         type: CONFERENCE_JOINED,
185 187
         conference
@@ -196,7 +198,7 @@ export function conferenceJoined(conference) {
196 198
  *     conference: JitsiConference
197 199
  * }}
198 200
  */
199
-export function conferenceLeft(conference) {
201
+export function conferenceLeft(conference: Object) {
200 202
     return {
201 203
         type: CONFERENCE_LEFT,
202 204
         conference
@@ -212,8 +214,8 @@ export function conferenceLeft(conference) {
212 214
  * local participant will (try to) join.
213 215
  * @returns {Function}
214 216
  */
215
-function _conferenceWillJoin(conference) {
216
-    return (dispatch, getState) => {
217
+function _conferenceWillJoin(conference: Object) {
218
+    return (dispatch: Dispatch<*>, getState: Function) => {
217 219
         const localTracks
218 220
             = getState()['features/base/tracks']
219 221
                 .filter(t => t.local)
@@ -243,7 +245,7 @@ function _conferenceWillJoin(conference) {
243 245
  *     conference: JitsiConference
244 246
  * }}
245 247
  */
246
-export function conferenceWillLeave(conference) {
248
+export function conferenceWillLeave(conference: Object) {
247 249
     return {
248 250
         type: CONFERENCE_WILL_LEAVE,
249 251
         conference
@@ -256,7 +258,7 @@ export function conferenceWillLeave(conference) {
256 258
  * @returns {Function}
257 259
  */
258 260
 export function createConference() {
259
-    return (dispatch: Dispatch<*>, getState: Function) => {
261
+    return (dispatch: Function, getState: Function) => {
260 262
         const state = getState();
261 263
         const { connection, locationURL } = state['features/base/connection'];
262 264
 
@@ -331,7 +333,7 @@ export function dataChannelOpened() {
331 333
  *     locked: boolean
332 334
  * }}
333 335
  */
334
-export function lockStateChanged(conference, locked) {
336
+export function lockStateChanged(conference: Object, locked: boolean) {
335 337
     return {
336 338
         type: LOCK_STATE_CHANGED,
337 339
         conference,
@@ -348,7 +350,7 @@ export function lockStateChanged(conference, locked) {
348 350
  *     p2p: boolean
349 351
  * }}
350 352
  */
351
-export function p2pStatusChanged(p2p) {
353
+export function p2pStatusChanged(p2p: boolean) {
352 354
     return {
353 355
         type: P2P_STATUS_CHANGED,
354 356
         p2p
@@ -365,7 +367,7 @@ export function p2pStatusChanged(p2p) {
365 367
  *     audioOnly: boolean
366 368
  * }}
367 369
  */
368
-export function setAudioOnly(audioOnly) {
370
+export function setAudioOnly(audioOnly: boolean) {
369 371
     return {
370 372
         type: SET_AUDIO_ONLY,
371 373
         audioOnly
@@ -412,7 +414,10 @@ export function setLastN(lastN: ?number) {
412 414
  * is to be joined or locked.
413 415
  * @returns {Function}
414 416
  */
415
-export function setPassword(conference, method: Function, password: string) {
417
+export function setPassword(
418
+        conference: Object,
419
+        method: Function,
420
+        password: string) {
416 421
     return (dispatch: Dispatch<*>, getState: Function) => {
417 422
         switch (method) {
418 423
         case conference.join: {

+ 11
- 10
react/features/base/util/uri.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 /**
2 4
  * The {@link RegExp} pattern of the authority of a URI.
3 5
  *
@@ -41,7 +43,7 @@ function _fixURIStringHierPart(uri) {
41 43
         = new RegExp(
42 44
             `^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`,
43 45
             'gi');
44
-    let match = regex.exec(uri);
46
+    let match: Array<string> | null = regex.exec(uri);
45 47
 
46 48
     if (!match) {
47 49
         // enso.me
@@ -80,7 +82,7 @@ function _fixURIStringHierPart(uri) {
80 82
  */
81 83
 function _fixURIStringScheme(uri: string) {
82 84
     const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi');
83
-    const match = regex.exec(uri);
85
+    const match: Array<string> | null = regex.exec(uri);
84 86
 
85 87
     if (match) {
86 88
         // As an implementation convenience, pick up the last scheme and make
@@ -115,8 +117,7 @@ function _fixURIStringScheme(uri: string) {
115 117
  * @returns {string} - The (Web application) context root defined by the
116 118
  * specified {@code location} (URI).
117 119
  */
118
-export function getLocationContextRoot(location: Object) {
119
-    const pathname = location.pathname;
120
+export function getLocationContextRoot({ pathname }: { pathname: string }) {
120 121
     const contextRootEndIndex = pathname.lastIndexOf('/');
121 122
 
122 123
     return (
@@ -169,12 +170,12 @@ function _objectToURLParamsArray(obj = {}) {
169 170
 export function parseStandardURIString(str: string) {
170 171
     /* eslint-disable no-param-reassign */
171 172
 
172
-    const obj = {
173
+    const obj: Object = {
173 174
         toString: _standardURIToString
174 175
     };
175 176
 
176 177
     let regex;
177
-    let match;
178
+    let match: Array<string> | null;
178 179
 
179 180
     // protocol
180 181
     regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi');
@@ -188,7 +189,7 @@ export function parseStandardURIString(str: string) {
188 189
     regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi');
189 190
     match = regex.exec(str);
190 191
     if (match) {
191
-        let authority = match[1].substring(/* // */ 2);
192
+        let authority: string = match[1].substring(/* // */ 2);
192 193
 
193 194
         str = str.substring(regex.lastIndex);
194 195
 
@@ -217,7 +218,7 @@ export function parseStandardURIString(str: string) {
217 218
     regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi');
218 219
     match = regex.exec(str);
219 220
 
220
-    let pathname;
221
+    let pathname: ?string;
221 222
 
222 223
     if (match) {
223 224
         pathname = match[1];
@@ -360,7 +361,7 @@ export function urlObjectToString(o: Object): ?string {
360 361
 
361 362
     // protocol
362 363
     if (!url.protocol) {
363
-        let protocol = o.protocol || o.scheme;
364
+        let protocol: ?string = o.protocol || o.scheme;
364 365
 
365 366
         if (protocol) {
366 367
             // Protocol is supposed to be the scheme and the final ':'. Anyway,
@@ -378,7 +379,7 @@ export function urlObjectToString(o: Object): ?string {
378 379
         //
379 380
         // It may be host/hostname and pathname with the latter denoting the
380 381
         // tenant.
381
-        const domain = o.domain || o.host || o.hostname;
382
+        const domain: ?string = o.domain || o.host || o.hostname;
382 383
 
383 384
         if (domain) {
384 385
             const { host, hostname, pathname: contextRoot, port }

+ 7
- 5
react/features/connection-indicator/statsEmitter.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import _ from 'lodash';
2 4
 
3 5
 import JitsiMeetJS from '../base/lib-jitsi-meet';
@@ -25,7 +27,7 @@ const statsEmitter = {
25 27
      * {@code statsEmitter} should subscribe for stat updates.
26 28
      * @returns {void}
27 29
      */
28
-    startListeningForStats(conference) {
30
+    startListeningForStats(conference: Object) {
29 31
         const { connectionQuality } = JitsiMeetJS.events;
30 32
 
31 33
         conference.on(connectionQuality.LOCAL_STATS_UPDATED,
@@ -44,7 +46,7 @@ const statsEmitter = {
44 46
      * user have been updated.
45 47
      * @returns {void}
46 48
      */
47
-    subscribeToClientStats(id, callback) {
49
+    subscribeToClientStats(id: ?string, callback: Function) {
48 50
         if (!id) {
49 51
             return;
50 52
         }
@@ -66,7 +68,7 @@ const statsEmitter = {
66 68
      * stat updates for the specified user id.
67 69
      * @returns {void}
68 70
      */
69
-    unsubscribeToClientStats(id, callback) {
71
+    unsubscribeToClientStats(id: string, callback: Function) {
70 72
         if (!subscribers[id]) {
71 73
             return;
72 74
         }
@@ -89,7 +91,7 @@ const statsEmitter = {
89 91
      * @param {Object} stats - New connection stats for the user.
90 92
      * @returns {void}
91 93
      */
92
-    _emitStatsUpdate(id, stats = {}) {
94
+    _emitStatsUpdate(id: string, stats: Object = {}) {
93 95
         const callbacks = subscribers[id] || [];
94 96
 
95 97
         callbacks.forEach(callback => {
@@ -107,7 +109,7 @@ const statsEmitter = {
107 109
      * by the library.
108 110
      * @returns {void}
109 111
      */
110
-    _onStatsUpdated(currentUserId, stats) {
112
+    _onStatsUpdated(currentUserId: string, stats: Object) {
111 113
         const allUserFramerates = stats.framerate || {};
112 114
         const allUserResolutions = stats.resolution || {};
113 115
 

+ 4
- 5
react/features/device-selection/popup.js Dosyayı Görüntüle

@@ -1,17 +1,16 @@
1
+/* global JitsiMeetJS */
2
+
1 3
 import 'aui-css';
2 4
 import 'aui-experimental-css';
3 5
 
4 6
 import DeviceSelectionPopup from './DeviceSelectionPopup';
5 7
 
6
-declare var JitsiMeetJS: Object;
7
-
8 8
 let deviceSelectionPopup;
9 9
 
10
-window.init = function(i18next) {
10
+window.init = i18next => {
11 11
     JitsiMeetJS.init({}).then(() => {
12 12
         deviceSelectionPopup = new DeviceSelectionPopup(i18next);
13 13
     });
14 14
 };
15 15
 
16
-window.addEventListener('beforeunload', () =>
17
-    deviceSelectionPopup.close());
16
+window.addEventListener('beforeunload', () => deviceSelectionPopup.close());

+ 7
- 5
react/features/dial-out/actions.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import {
2 4
     DIAL_OUT_CANCELED,
3 5
     DIAL_OUT_CODES_UPDATED,
@@ -25,8 +27,8 @@ export function cancel() {
25 27
  * @param {string} dialNumber - The number to dial.
26 28
  * @returns {Function}
27 29
  */
28
-export function dial(dialNumber) {
29
-    return (dispatch, getState) => {
30
+export function dial(dialNumber: string) {
31
+    return (dispatch: Dispatch<*>, getState: Function) => {
30 32
         const { conference } = getState()['features/base/conference'];
31 33
 
32 34
         conference.dial(dialNumber);
@@ -39,8 +41,8 @@ export function dial(dialNumber) {
39 41
  * @param {string} dialNumber - The dial number to check for validity.
40 42
  * @returns {Function}
41 43
  */
42
-export function checkDialNumber(dialNumber) {
43
-    return (dispatch, getState) => {
44
+export function checkDialNumber(dialNumber: string) {
45
+    return (dispatch: Dispatch<*>, getState: Function) => {
44 46
         const { dialOutAuthUrl } = getState()['features/base/config'];
45 47
 
46 48
         if (!dialOutAuthUrl) {
@@ -78,7 +80,7 @@ export function checkDialNumber(dialNumber) {
78 80
  * @returns {Function}
79 81
  */
80 82
 export function updateDialOutCodes() {
81
-    return (dispatch, getState) => {
83
+    return (dispatch: Dispatch<*>, getState: Function) => {
82 84
         const { dialOutCodesUrl } = getState()['features/base/config'];
83 85
 
84 86
         if (!dialOutCodesUrl) {

+ 11
- 10
react/features/feedback/actions.js Dosyayı Görüntüle

@@ -1,11 +1,9 @@
1
-import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors';
1
+// @flow
2 2
 
3 3
 import { openDialog } from '../../features/base/dialog';
4
+import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors';
4 5
 
5
-import {
6
-    CANCEL_FEEDBACK,
7
-    SUBMIT_FEEDBACK
8
-} from './actionTypes';
6
+import { CANCEL_FEEDBACK, SUBMIT_FEEDBACK } from './actionTypes';
9 7
 import { FeedbackDialog } from './components';
10 8
 
11 9
 declare var config: Object;
@@ -23,7 +21,7 @@ declare var interfaceConfig: Object;
23 21
  *     score: number
24 22
  * }}
25 23
  */
26
-export function cancelFeedback(score, message) {
24
+export function cancelFeedback(score: number, message: string) {
27 25
     return {
28 26
         type: CANCEL_FEEDBACK,
29 27
         message,
@@ -42,8 +40,8 @@ export function cancelFeedback(score, message) {
42 40
  * resolved with true if the dialog is disabled or the feedback was already
43 41
  * submitted. Rejected if another dialog is already displayed.
44 42
  */
45
-export function maybeOpenFeedbackDialog(conference) {
46
-    return (dispatch, getState) => {
43
+export function maybeOpenFeedbackDialog(conference: Object) {
44
+    return (dispatch: Dispatch<*>, getState: Function) => {
47 45
         const state = getState();
48 46
 
49 47
         if (interfaceConfig.filmStripOnly || config.iAmRecorder) {
@@ -93,7 +91,7 @@ export function maybeOpenFeedbackDialog(conference) {
93 91
  * is closed.
94 92
  * @returns {Object}
95 93
  */
96
-export function openFeedbackDialog(conference, onClose) {
94
+export function openFeedbackDialog(conference: Object, onClose: ?Function) {
97 95
     return openDialog(FeedbackDialog, {
98 96
         conference,
99 97
         onClose
@@ -113,7 +111,10 @@ export function openFeedbackDialog(conference, onClose) {
113 111
  *     type: SUBMIT_FEEDBACK
114 112
  * }}
115 113
  */
116
-export function submitFeedback(score, message, conference) {
114
+export function submitFeedback(
115
+        score: number,
116
+        message: string,
117
+        conference: Object) {
117 118
     conference.sendFeedback(score, message);
118 119
 
119 120
     return {

+ 4
- 2
react/features/invite/actions.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { openDialog } from '../../features/base/dialog';
2 4
 
3 5
 import {
@@ -27,7 +29,7 @@ export function openInviteDialog() {
27 29
  *     visible: boolean
28 30
  * }}
29 31
  */
30
-export function setInfoDialogVisibility(visible) {
32
+export function setInfoDialogVisibility(visible: boolean) {
31 33
     return {
32 34
         type: SET_INFO_DIALOG_VISIBILITY,
33 35
         visible
@@ -40,7 +42,7 @@ export function setInfoDialogVisibility(visible) {
40 42
  * @returns {Function}
41 43
  */
42 44
 export function updateDialInNumbers() {
43
-    return (dispatch, getState) => {
45
+    return (dispatch: Dispatch<*>, getState: Function) => {
44 46
         const state = getState();
45 47
         const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
46 48
             = state['features/base/config'];

+ 50
- 44
react/features/invite/functions.js Dosyayı Görüntüle

@@ -1,31 +1,18 @@
1
+// @flow
2
+
1 3
 declare var $: Function;
2 4
 declare var interfaceConfig: Object;
3 5
 
4 6
 /**
5
- * Sends an ajax request to a directory service.
7
+ * Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS
8
+ * list.
6 9
  *
7
- * @param {string} serviceUrl - The service to query.
8
- * @param {string} jwt - The jwt token to pass to the search service.
9
- * @param {string} text - Text to search.
10
- * @param {Array<string>} queryTypes - Array with the query types that will be
11
- * executed - "conferenceRooms" | "user" | "room".
12
- * @returns {Promise} - The promise created by the request.
10
+ * @param {string} name - The invite option name.
11
+ * @private
12
+ * @returns {number} - The position of the option in the list.
13 13
  */
14
-export function searchPeople( // eslint-disable-line max-params
15
-        serviceUrl,
16
-        jwt,
17
-        text,
18
-        queryTypes = [ 'conferenceRooms', 'user', 'room' ]) {
19
-    const queryTypesString = JSON.stringify(queryTypes);
20
-
21
-    return new Promise((resolve, reject) => {
22
-        $.getJSON(`${serviceUrl}?query=${encodeURIComponent(text)}`
23
-            + `&queryTypes=${queryTypesString}&jwt=${jwt}`,
24
-        response => resolve(response)
25
-        ).fail((jqxhr, textStatus, error) =>
26
-            reject(error)
27
-        );
28
-    });
14
+export function getInviteOptionPosition(name: string): number {
15
+    return interfaceConfig.INVITE_OPTIONS.indexOf(name);
29 16
 }
30 17
 
31 18
 /**
@@ -38,17 +25,21 @@ export function searchPeople( // eslint-disable-line max-params
38 25
  * @param {Immutable.List} people - The list of the "user" type items to invite.
39 26
  * @returns {Promise} - The promise created by the request.
40 27
  */
41
-export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // eslint-disable-line max-params, max-len
28
+export function invitePeople( // eslint-disable-line max-params
29
+        inviteServiceUrl: string,
30
+        inviteUrl: string,
31
+        jwt: string,
32
+        people: Object) {
42 33
     return new Promise((resolve, reject) => {
43
-        $.post(`${inviteServiceUrl}?token=${jwt}`,
44
-            JSON.stringify({
45
-                'invited': people,
46
-                'url': inviteUrl }),
47
-            response => resolve(response),
48
-            'json')
49
-            .fail((jqxhr, textStatus, error) =>
50
-                reject(error)
51
-            );
34
+        $.post(
35
+                `${inviteServiceUrl}?token=${jwt}`,
36
+                JSON.stringify({
37
+                    'invited': people,
38
+                    'url': inviteUrl
39
+                }),
40
+                resolve,
41
+                'json')
42
+            .fail((jqxhr, textStatus, error) => reject(error));
52 43
     });
53 44
 }
54 45
 
@@ -61,10 +52,11 @@ export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // esli
61 52
  * invite.
62 53
  * @returns {void}
63 54
  */
64
-export function inviteRooms(conference, rooms) {
55
+export function inviteRooms(
56
+        conference: { createVideoSIPGWSession: Function },
57
+        rooms: Object) {
65 58
     for (const room of rooms) {
66
-        const sipAddress = room.id;
67
-        const displayName = room.name;
59
+        const { id: sipAddress, name: displayName } = room;
68 60
 
69 61
         if (sipAddress && displayName) {
70 62
             const newSession
@@ -86,18 +78,32 @@ export function inviteRooms(conference, rooms) {
86 78
  * @returns {boolean} - True to indicate that the given invite option is
87 79
  * enabled, false - otherwise.
88 80
  */
89
-export function isInviteOptionEnabled(name) {
90
-    return interfaceConfig.INVITE_OPTIONS.indexOf(name) !== -1;
81
+export function isInviteOptionEnabled(name: string) {
82
+    return getInviteOptionPosition(name) !== -1;
91 83
 }
92 84
 
93 85
 /**
94
- * Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS
95
- * list.
86
+ * Sends an ajax request to a directory service.
96 87
  *
97
- * @param {string} optionName - The invite option name.
98
- * @private
99
- * @returns {number} - The position of the option in the list.
88
+ * @param {string} serviceUrl - The service to query.
89
+ * @param {string} jwt - The jwt token to pass to the search service.
90
+ * @param {string} text - Text to search.
91
+ * @param {Array<string>} queryTypes - Array with the query types that will be
92
+ * executed - "conferenceRooms" | "user" | "room".
93
+ * @returns {Promise} - The promise created by the request.
100 94
  */
101
-export function getInviteOptionPosition(optionName) {
102
-    return interfaceConfig.INVITE_OPTIONS.indexOf(optionName);
95
+export function searchPeople( // eslint-disable-line max-params
96
+        serviceUrl: string,
97
+        jwt: string,
98
+        text: string,
99
+        queryTypes: Array<string> = [ 'conferenceRooms', 'user', 'room' ]) {
100
+    const queryTypesString = JSON.stringify(queryTypes);
101
+
102
+    return new Promise((resolve, reject) => {
103
+        $.getJSON(
104
+                `${serviceUrl}?query=${encodeURIComponent(text)}&queryTypes=${
105
+                    queryTypesString}&jwt=${jwt}`,
106
+                resolve)
107
+            .fail((jqxhr, textStatus, error) => reject(error));
108
+    });
103 109
 }

+ 3
- 1
react/features/toolbox/functions.web.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import SideContainerToggler
2 4
     from '../../../modules/UI/side_pannels/SideContainerToggler';
3 5
 
@@ -101,7 +103,7 @@ export function getToolbarClassNames(props: Object) {
101 103
  * @returns {boolean} - True to indicate that the given toolbar button
102 104
  * is enabled, false - otherwise.
103 105
  */
104
-export function isButtonEnabled(name) {
106
+export function isButtonEnabled(name: string) {
105 107
     return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1
106 108
             || interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) !== -1;
107 109
 }

Loading…
İptal
Kaydet