Przeglądaj źródła

Partially prepare for eslint-plugin-flowtype 2.37.0

master
Lyubo Marinov 7 lat temu
rodzic
commit
5561a9c031

+ 6
- 1
modules/API/API.js Wyświetl plik

1
+// @flow
2
+
1
 import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
3
 import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
2
 import { parseJWTFromURLParams } from '../../react/features/jwt';
4
 import { parseJWTFromURLParams } from '../../react/features/jwt';
3
 import { getJitsiMeetTransport } from '../transport';
5
 import { getJitsiMeetTransport } from '../transport';
207
      * @param {Object} options - Object with the message properties.
209
      * @param {Object} options - Object with the message properties.
208
      * @returns {void}
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
         if (APP.conference.isLocalId(id)) {
216
         if (APP.conference.isLocalId(id)) {
212
             return;
217
             return;
213
         }
218
         }

+ 16
- 11
react/features/base/conference/actions.js Wyświetl plik

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

+ 11
- 10
react/features/base/util/uri.js Wyświetl plik

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

+ 7
- 5
react/features/connection-indicator/statsEmitter.js Wyświetl plik

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

+ 4
- 5
react/features/device-selection/popup.js Wyświetl plik

1
+/* global JitsiMeetJS */
2
+
1
 import 'aui-css';
3
 import 'aui-css';
2
 import 'aui-experimental-css';
4
 import 'aui-experimental-css';
3
 
5
 
4
 import DeviceSelectionPopup from './DeviceSelectionPopup';
6
 import DeviceSelectionPopup from './DeviceSelectionPopup';
5
 
7
 
6
-declare var JitsiMeetJS: Object;
7
-
8
 let deviceSelectionPopup;
8
 let deviceSelectionPopup;
9
 
9
 
10
-window.init = function(i18next) {
10
+window.init = i18next => {
11
     JitsiMeetJS.init({}).then(() => {
11
     JitsiMeetJS.init({}).then(() => {
12
         deviceSelectionPopup = new DeviceSelectionPopup(i18next);
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 Wyświetl plik

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

+ 11
- 10
react/features/feedback/actions.js Wyświetl plik

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

+ 4
- 2
react/features/invite/actions.js Wyświetl plik

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

+ 50
- 44
react/features/invite/functions.js Wyświetl plik

1
+// @flow
2
+
1
 declare var $: Function;
3
 declare var $: Function;
2
 declare var interfaceConfig: Object;
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
  * @param {Immutable.List} people - The list of the "user" type items to invite.
25
  * @param {Immutable.List} people - The list of the "user" type items to invite.
39
  * @returns {Promise} - The promise created by the request.
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
     return new Promise((resolve, reject) => {
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
  * invite.
52
  * invite.
62
  * @returns {void}
53
  * @returns {void}
63
  */
54
  */
64
-export function inviteRooms(conference, rooms) {
55
+export function inviteRooms(
56
+        conference: { createVideoSIPGWSession: Function },
57
+        rooms: Object) {
65
     for (const room of rooms) {
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
         if (sipAddress && displayName) {
61
         if (sipAddress && displayName) {
70
             const newSession
62
             const newSession
86
  * @returns {boolean} - True to indicate that the given invite option is
78
  * @returns {boolean} - True to indicate that the given invite option is
87
  * enabled, false - otherwise.
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 Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz