Bläddra i källkod

ref(TS) Convert more base files to TS (#12222)

factor2
Robert Pintilii 2 år sedan
förälder
incheckning
0bccda2c9e
Inget konto är kopplat till bidragsgivarens mejladress

react/features/base/app/actions.js → react/features/base/app/actions.ts Visa fil

@@ -1,11 +1,7 @@
1
-// @flow
2
-
3
-import type { Dispatch } from 'redux';
1
+import { IStore } from '../../app/types';
4 2
 
5 3
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
6 4
 
7
-declare var APP;
8
-
9 5
 /**
10 6
  * Signals that a specific App will mount (in the terms of React).
11 7
  *
@@ -16,7 +12,7 @@ declare var APP;
16 12
  * }}
17 13
  */
18 14
 export function appWillMount(app: Object) {
19
-    return (dispatch: Dispatch<any>) => {
15
+    return (dispatch: IStore['dispatch']) => {
20 16
         // TODO There was a redux action creator appInit which I did not like
21 17
         // because we already had the redux action creator appWillMount and,
22 18
         // respectively, the redux action APP_WILL_MOUNT. So I set out to remove

react/features/base/app/functions.js → react/features/base/app/functions.ts Visa fil

@@ -1,19 +1,19 @@
1
-// @flow
1
+import { toState } from '../redux/functions';
2 2
 
3
-import { toState } from '../redux';
3
+import { IStateful } from './types';
4 4
 
5 5
 /**
6 6
  * Gets the value of a specific React {@code Component} prop of the currently
7 7
  * mounted {@link App}.
8 8
  *
9
- * @param {Function|Object} stateful - The redux store or {@code getState}
9
+ * @param {IStateful} stateful - The redux store or {@code getState}
10 10
  * function.
11 11
  * @param {string} propName - The name of the React {@code Component} prop of
12 12
  * the currently mounted {@code App} to get.
13 13
  * @returns {*} The value of the specified React {@code Component} prop of the
14 14
  * currently mounted {@code App}.
15 15
  */
16
-export function getAppProp(stateful: Function | Object, propName: string) {
16
+export function getAppProp(stateful: IStateful, propName: string) {
17 17
     const state = toState(stateful)['features/base/app'];
18 18
 
19 19
     if (state) {

react/features/base/app/logger.js → react/features/base/app/logger.ts Visa fil

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 import { getLogger } from '../logging/functions';
4 2
 
5 3
 export default getLogger('features/base/app');

+ 1
- 1
react/features/base/app/reducer.ts Visa fil

@@ -3,7 +3,7 @@ import ReducerRegistry from '../redux/ReducerRegistry';
3 3
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
4 4
 
5 5
 export interface IAppState {
6
-    app?: Object | undefined;
6
+    app?: any;
7 7
 }
8 8
 
9 9
 ReducerRegistry.register<IAppState>('features/base/app', (state = {}, action): IAppState => {

+ 1
- 1
react/features/base/config/configType.ts Visa fil

@@ -425,7 +425,7 @@ export interface IConfig {
425 425
     };
426 426
     serviceUrl?: string;
427 427
     speakerStatsOrder?: Array<'role' | 'name' | 'hasLeft'>;
428
-    startAudioMuted?: boolean;
428
+    startAudioMuted?: number;
429 429
     startAudioOnly?: boolean;
430 430
     startLastN?: number;
431 431
     startScreenSharing?: boolean;

react/features/base/devices/middleware.js → react/features/base/devices/middleware.ts Visa fil

@@ -1,18 +1,21 @@
1
-/* global APP */
1
+import { AnyAction } from 'redux';
2 2
 
3
+/* eslint-disable lines-around-comment */
4
+// @ts-ignore
3 5
 import UIEvents from '../../../../service/UI/UIEvents';
4
-import { processExternalDeviceRequest } from '../../device-selection';
5
-import {
6
-    NOTIFICATION_TIMEOUT_TYPE,
7
-    showNotification,
8
-    showWarningNotification
9
-} from '../../notifications';
6
+import { IStore } from '../../app/types';
7
+import { processExternalDeviceRequest } from '../../device-selection/functions';
8
+import { showNotification, showWarningNotification } from '../../notifications/actions';
9
+import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
10
+// @ts-ignore
10 11
 import { replaceAudioTrackById, replaceVideoTrackById, setDeviceStatusWarning } from '../../prejoin/actions';
12
+// @ts-ignore
11 13
 import { isPrejoinPageVisible } from '../../prejoin/functions';
12
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
14
+import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
13 15
 import JitsiMeetJS, { JitsiMediaDevicesEvents, JitsiTrackErrors } from '../lib-jitsi-meet';
14
-import { MiddlewareRegistry } from '../redux';
15
-import { updateSettings } from '../settings';
16
+import MiddlewareRegistry from '../redux/MiddlewareRegistry';
17
+import { updateSettings } from '../settings/actions';
18
+
16 19
 
17 20
 import {
18 21
     CHECK_AND_NOTIFY_FOR_NEW_DEVICE,
@@ -35,6 +38,7 @@ import {
35 38
     setAudioOutputDeviceId
36 39
 } from './functions';
37 40
 import logger from './logger';
41
+import { IDevicesState } from './reducer';
38 42
 
39 43
 const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
40 44
     microphone: {
@@ -57,7 +61,7 @@ const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
57 61
 /**
58 62
  * A listener for device permissions changed reported from lib-jitsi-meet.
59 63
  */
60
-let permissionsListener;
64
+let permissionsListener: Function | undefined;
61 65
 
62 66
 /**
63 67
  * Logs the current device list.
@@ -65,8 +69,9 @@ let permissionsListener;
65 69
  * @param {Object} deviceList - Whatever is returned by {@link groupDevicesByKind}.
66 70
  * @returns {string}
67 71
  */
68
-function logDeviceList(deviceList) {
69
-    const devicesToStr = list => list.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n');
72
+function logDeviceList(deviceList: IDevicesState['availableDevices']) {
73
+    const devicesToStr = (list?: MediaDeviceInfo[]) =>
74
+        list?.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n');
70 75
     const audioInputs = devicesToStr(deviceList.audioInput);
71 76
     const audioOutputs = devicesToStr(deviceList.audioOutput);
72 77
     const videoInputs = devicesToStr(deviceList.videoInput);
@@ -87,7 +92,7 @@ function logDeviceList(deviceList) {
87 92
 MiddlewareRegistry.register(store => next => action => {
88 93
     switch (action.type) {
89 94
     case APP_WILL_MOUNT: {
90
-        const _permissionsListener = permissions => {
95
+        const _permissionsListener = (permissions: Object) => {
91 96
             store.dispatch(devicePermissionsChanged(permissions));
92 97
         };
93 98
         const { mediaDevices } = JitsiMeetJS;
@@ -214,7 +219,7 @@ MiddlewareRegistry.register(store => next => action => {
214 219
  * @private
215 220
  * @returns {Object} The value returned by {@code next(action)}.
216 221
  */
217
-function _processPendingRequests({ dispatch, getState }, next, action) {
222
+function _processPendingRequests({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
218 223
     const result = next(action);
219 224
     const state = getState();
220 225
     const { pendingRequests } = state['features/base/devices'];
@@ -223,7 +228,7 @@ function _processPendingRequests({ dispatch, getState }, next, action) {
223 228
         return result;
224 229
     }
225 230
 
226
-    pendingRequests.forEach(request => {
231
+    pendingRequests.forEach((request: any) => {
227 232
         processExternalDeviceRequest(
228 233
             dispatch,
229 234
             getState,
@@ -248,7 +253,7 @@ function _processPendingRequests({ dispatch, getState }, next, action) {
248 253
  * @private
249 254
  * @returns {void}
250 255
  */
251
-function _checkAndNotifyForNewDevice(store, newDevices, oldDevices) {
256
+function _checkAndNotifyForNewDevice(store: IStore, newDevices: MediaDeviceInfo[], oldDevices: MediaDeviceInfo[]) {
252 257
     const { dispatch } = store;
253 258
 
254 259
     // let's intersect both newDevices and oldDevices and handle thew newly
@@ -260,7 +265,9 @@ function _checkAndNotifyForNewDevice(store, newDevices, oldDevices) {
260 265
     // we group devices by groupID which normally is the grouping by physical device
261 266
     // plugging in headset we provide normally two device, one input and one output
262 267
     // and we want to show only one notification for this physical audio device
263
-    const devicesGroupBy = onlyNewDevices.reduce((accumulated, value) => {
268
+    const devicesGroupBy: {
269
+        [key: string]: MediaDeviceInfo[];
270
+    } = onlyNewDevices.reduce((accumulated: any, value) => {
264 271
         accumulated[value.groupId] = accumulated[value.groupId] || [];
265 272
         accumulated[value.groupId].push(value);
266 273
 
@@ -314,7 +321,7 @@ function _checkAndNotifyForNewDevice(store, newDevices, oldDevices) {
314 321
  * @returns {boolean} - Returns true in order notifications to be dismissed.
315 322
  * @private
316 323
  */
317
-function _useDevice({ dispatch }, devices) {
324
+function _useDevice({ dispatch }: IStore, devices: MediaDeviceInfo[]) {
318 325
     devices.forEach(device => {
319 326
         switch (device.kind) {
320 327
         case 'videoinput': {

react/features/base/jwt/actions.js → react/features/base/jwt/actions.ts Visa fil

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 import { SET_JWT } from './actionTypes';
4 2
 
5 3
 /**
@@ -11,7 +9,7 @@ import { SET_JWT } from './actionTypes';
11 9
  *     jwt: (string|undefined)
12 10
  * }}
13 11
  */
14
-export function setJWT(jwt: ?string) {
12
+export function setJWT(jwt?: string) {
15 13
     return {
16 14
         type: SET_JWT,
17 15
         jwt

react/features/base/jwt/constants.js → react/features/base/jwt/constants.ts Visa fil


react/features/base/lastn/actions.js → react/features/base/lastn/actions.ts Visa fil

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 import { SET_LAST_N } from './actionTypes';
4 2
 
5 3
 /**

react/features/base/lastn/functions.js → react/features/base/lastn/functions.ts Visa fil

@@ -7,7 +7,7 @@ import { VIDEO_QUALITY_LEVELS } from '../../video-quality/constants';
7 7
  * @param {number} channelLastN - LastN value set for the whole conference.
8 8
  * @returns {number} LastN value applicable to the quality level specified.
9 9
  */
10
-export function getLastNForQualityLevel(qualityLevel, channelLastN) {
10
+export function getLastNForQualityLevel(qualityLevel: number, channelLastN: number) {
11 11
     let lastN = channelLastN;
12 12
 
13 13
     const videoQualityLevels = Object.values(VIDEO_QUALITY_LEVELS);
@@ -15,8 +15,8 @@ export function getLastNForQualityLevel(qualityLevel, channelLastN) {
15 15
     for (const lvl in videoQualityLevels) {
16 16
         if (videoQualityLevels.hasOwnProperty(lvl)
17 17
             && qualityLevel === videoQualityLevels[lvl]
18
-            && lvl > 1) {
19
-            lastN = Math.floor(channelLastN / Math.pow(2, lvl - 1));
18
+            && Number(lvl) > 1) {
19
+            lastN = Math.floor(channelLastN / Math.pow(2, Number(lvl) - 1));
20 20
         }
21 21
     }
22 22
 
@@ -30,7 +30,7 @@ export function getLastNForQualityLevel(qualityLevel, channelLastN) {
30 30
  * @param {Object} lastNLimits - The Object to be verified.
31 31
  * @returns {undefined|Map<number, number>}
32 32
  */
33
-export function validateLastNLimits(lastNLimits) {
33
+export function validateLastNLimits(lastNLimits: any) {
34 34
     // Checks if only numbers are used
35 35
     if (typeof lastNLimits !== 'object'
36 36
         || !Object.keys(lastNLimits).length
@@ -64,7 +64,7 @@ export function validateLastNLimits(lastNLimits) {
64 64
  * @returns {number|undefined} - A "last N" number if there was a corresponding "last N" value matched with the number
65 65
  * of participants or {@code undefined} otherwise.
66 66
  */
67
-export function limitLastN(participantsCount, lastNLimits) {
67
+export function limitLastN(participantsCount: number, lastNLimits: Map<number, number>) {
68 68
     if (!lastNLimits || !lastNLimits.keys) {
69 69
         return undefined;
70 70
     }

react/features/base/lastn/logger.js → react/features/base/lastn/logger.ts Visa fil

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 import { getLogger } from '../logging/functions';
4 2
 
5 3
 export default getLogger('features/base/lastn');

react/features/base/lastn/middleware.js → react/features/base/lastn/middleware.ts Visa fil

@@ -1,7 +1,6 @@
1
-// @flow
2
-
3 1
 import debounce from 'lodash/debounce';
4 2
 
3
+import { IStore } from '../../app/types';
5 4
 import { SET_FILMSTRIP_ENABLED } from '../../filmstrip/actionTypes';
6 5
 import { SELECT_LARGE_VIDEO_PARTICIPANT } from '../../large-video/actionTypes';
7 6
 import { APP_STATE_CHANGED } from '../../mobile/background/actionTypes';
@@ -22,7 +21,9 @@ import {
22 21
     getParticipantById,
23 22
     getParticipantCount
24 23
 } from '../participants/functions';
25
-import { MiddlewareRegistry } from '../redux';
24
+import MiddlewareRegistry from '../redux/MiddlewareRegistry';
25
+// eslint-disable-next-line lines-around-comment
26
+// @ts-ignore
26 27
 import { isLocalVideoTrackDesktop } from '../tracks/functions';
27 28
 
28 29
 import { setLastN } from './actions';
@@ -36,7 +37,7 @@ import logger from './logger';
36 37
  * @private
37 38
  * @returns {void}
38 39
  */
39
-const _updateLastN = debounce(({ dispatch, getState }) => {
40
+const _updateLastN = debounce(({ dispatch, getState }: IStore) => {
40 41
     const state = getState();
41 42
     const { conference } = state['features/base/conference'];
42 43
 
@@ -61,6 +62,7 @@ const _updateLastN = debounce(({ dispatch, getState }) => {
61 62
     let lastNSelected = config.startLastN ?? (config.channelLastN ?? -1);
62 63
 
63 64
     // Apply last N limit based on the # of participants and config settings.
65
+    // @ts-ignore
64 66
     const limitedLastN = limitLastN(participantCount, lastNLimits);
65 67
 
66 68
     if (limitedLastN !== undefined) {
@@ -81,7 +83,7 @@ const _updateLastN = debounce(({ dispatch, getState }) => {
81 83
         // view since we make an exception only for screenshare when in audio-only mode. If the user unpins
82 84
         // the screenshare, lastN will be set to 0 here. It will be set to 1 if screenshare has been auto pinned.
83 85
         if (!tileViewEnabled && largeVideoParticipant && !largeVideoParticipant.local) {
84
-            lastNSelected = (remoteScreenShares || []).includes(largeVideoParticipantId) ? 1 : 0;
86
+            lastNSelected = (remoteScreenShares || []).includes(largeVideoParticipantId ?? '') ? 1 : 0;
85 87
         } else {
86 88
             lastNSelected = 0;
87 89
         }

react/features/base/participants/middleware.js → react/features/base/participants/middleware.ts Visa fil

@@ -1,36 +1,35 @@
1
-// @flow
2
-
3 1
 import i18n from 'i18next';
4 2
 import { batch } from 'react-redux';
5 3
 
4
+// @ts-ignore
6 5
 import UIEvents from '../../../../service/UI/UIEvents';
6
+import { IStore } from '../../app/types';
7 7
 import { approveParticipant } from '../../av-moderation/actions';
8 8
 import { UPDATE_BREAKOUT_ROOMS } from '../../breakout-rooms/actionTypes';
9 9
 import { getBreakoutRooms } from '../../breakout-rooms/functions';
10 10
 import { toggleE2EE } from '../../e2ee/actions';
11 11
 import { MAX_MODE } from '../../e2ee/constants';
12
+import { showNotification } from '../../notifications/actions';
12 13
 import {
13 14
     LOCAL_RECORDING_NOTIFICATION_ID,
14 15
     NOTIFICATION_TIMEOUT_TYPE,
15
-    RAISE_HAND_NOTIFICATION_ID,
16
-    showNotification
17
-} from '../../notifications';
16
+    RAISE_HAND_NOTIFICATION_ID
17
+} from '../../notifications/constants';
18 18
 import { isForceMuted } from '../../participants-pane/functions';
19
-import { CALLING, INVITED } from '../../presence-status';
19
+import { CALLING, INVITED } from '../../presence-status/constants';
20 20
 import { RAISE_HAND_SOUND_ID } from '../../reactions/constants';
21
-import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../../recording';
22
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
23
-import {
24
-    CONFERENCE_WILL_JOIN,
25
-    forEachConference,
26
-    getCurrentConference
27
-} from '../conference';
28
-import { SET_CONFIG } from '../config';
21
+import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../../recording/constants';
22
+import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
23
+import { CONFERENCE_WILL_JOIN } from '../conference/actionTypes';
24
+import { forEachConference, getCurrentConference } from '../conference/functions';
25
+import { IJitsiConference } from '../conference/reducer';
26
+import { SET_CONFIG } from '../config/actionTypes';
29 27
 import { getDisableRemoveRaisedHandOnFocus } from '../config/functions.any';
30 28
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
31
-import { MEDIA_TYPE } from '../media';
32
-import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
33
-import { playSound, registerSound, unregisterSound } from '../sounds';
29
+import { MEDIA_TYPE } from '../media/constants';
30
+import MiddlewareRegistry from '../redux/MiddlewareRegistry';
31
+import StateListenerRegistry from '../redux/StateListenerRegistry';
32
+import { playSound, registerSound, unregisterSound } from '../sounds/actions';
34 33
 
35 34
 import {
36 35
     DOMINANT_SPEAKER_CHANGED,
@@ -79,9 +78,9 @@ import {
79 78
 } from './functions';
80 79
 import logger from './logger';
81 80
 import { PARTICIPANT_JOINED_FILE, PARTICIPANT_LEFT_FILE } from './sounds';
82
-import './subscriber';
81
+import { IJitsiParticipant } from './types';
83 82
 
84
-declare var APP: Object;
83
+import './subscriber';
85 84
 
86 85
 /**
87 86
  * Middleware that captures CONFERENCE_JOINED and CONFERENCE_LEFT actions and
@@ -128,8 +127,7 @@ MiddlewareRegistry.register(store => next => action => {
128 127
         const participant = getDominantSpeakerParticipant(state);
129 128
 
130 129
         if (
131
-            participant
132
-            && participant.local
130
+            participant?.local
133 131
             && hasRaisedHand(participant)
134 132
             && action.level > LOWER_HAND_AUDIO_LEVEL
135 133
             && !getDisableRemoveRaisedHandOnFocus(state)
@@ -142,14 +140,14 @@ MiddlewareRegistry.register(store => next => action => {
142 140
     case GRANT_MODERATOR: {
143 141
         const { conference } = store.getState()['features/base/conference'];
144 142
 
145
-        conference.grantOwner(action.id);
143
+        conference?.grantOwner(action.id);
146 144
         break;
147 145
     }
148 146
 
149 147
     case KICK_PARTICIPANT: {
150 148
         const { conference } = store.getState()['features/base/conference'];
151 149
 
152
-        conference.kickParticipant(action.id);
150
+        conference?.kickParticipant(action.id);
153 151
         break;
154 152
     }
155 153
 
@@ -164,13 +162,13 @@ MiddlewareRegistry.register(store => next => action => {
164 162
             // participant is uniquely identified by the very fact that there is
165 163
             // only one local participant.
166 164
 
167
-            id: localId,
165
+            id: localId ?? '',
168 166
             local: true,
169 167
             raisedHandTimestamp
170 168
         }));
171 169
 
172 170
         store.dispatch(raiseHandUpdateQueue({
173
-            id: localId,
171
+            id: localId ?? '',
174 172
             raisedHandTimestamp
175 173
         }));
176 174
 
@@ -188,14 +186,16 @@ MiddlewareRegistry.register(store => next => action => {
188 186
         const { deploymentInfo } = state['features/base/config'];
189 187
 
190 188
         // if there userRegion set let's use it for the local participant
191
-        if (deploymentInfo && deploymentInfo.userRegion) {
189
+        if (deploymentInfo?.userRegion) {
192 190
             const localId = getLocalParticipant(state)?.id;
193 191
 
194
-            store.dispatch(participantUpdated({
195
-                id: localId,
196
-                local: true,
197
-                region: deploymentInfo.userRegion
198
-            }));
192
+            if (localId) {
193
+                store.dispatch(participantUpdated({
194
+                    id: localId,
195
+                    local: true,
196
+                    region: deploymentInfo.userRegion
197
+                }));
198
+            }
199 199
         }
200 200
 
201 201
         return result;
@@ -207,7 +207,7 @@ MiddlewareRegistry.register(store => next => action => {
207 207
         const localId = getLocalParticipant(state)?.id;
208 208
         const { localRecording } = state['features/base/config'];
209 209
 
210
-        if (localRecording?.notifyAllParticipants && !onlySelf) {
210
+        if (localRecording?.notifyAllParticipants && !onlySelf && localId) {
211 211
             store.dispatch(participantUpdated({
212 212
                 // XXX Only the local participant is allowed to update without
213 213
                 // stating the JitsiConference instance (i.e. participant property
@@ -227,7 +227,7 @@ MiddlewareRegistry.register(store => next => action => {
227 227
     case MUTE_REMOTE_PARTICIPANT: {
228 228
         const { conference } = store.getState()['features/base/conference'];
229 229
 
230
-        conference.muteParticipant(action.id, action.mediaType);
230
+        conference?.muteParticipant(action.id, action.mediaType);
231 231
         break;
232 232
     }
233 233
 
@@ -319,7 +319,7 @@ MiddlewareRegistry.register(store => next => action => {
319 319
         if (breakoutRoom) {
320 320
             const rooms = getBreakoutRooms(state);
321 321
             const roomCounter = state['features/breakout-rooms'].roomCounter;
322
-            const newRooms = {};
322
+            const newRooms: any = {};
323 323
 
324 324
             Object.entries(rooms).forEach(([ key, r ]) => {
325 325
                 const participants = r?.participants || {};
@@ -393,7 +393,7 @@ StateListenerRegistry.register(
393 393
     /* listener */ ({ leaving }, { dispatch, getState }) => {
394 394
         const state = getState();
395 395
         const localParticipant = getLocalParticipant(state);
396
-        let id;
396
+        let id: string;
397 397
 
398 398
         if (!localParticipant
399 399
                 || (id = localParticipant.id)
@@ -421,37 +421,41 @@ StateListenerRegistry.register(
421 421
     state => state['features/base/conference'].conference,
422 422
     (conference, store) => {
423 423
         if (conference) {
424
-            const propertyHandlers = {
425
-                'e2ee.enabled': (participant, value) => _e2eeUpdated(store, conference, participant.getId(), value),
426
-                'features_e2ee': (participant, value) =>
424
+            const propertyHandlers: {
425
+                [key: string]: Function;
426
+            } = {
427
+                'e2ee.enabled': (participant: IJitsiParticipant, value: string) =>
428
+                    _e2eeUpdated(store, conference, participant.getId(), value),
429
+                'features_e2ee': (participant: IJitsiParticipant, value: boolean) =>
427 430
                     store.dispatch(participantUpdated({
428 431
                         conference,
429 432
                         id: participant.getId(),
430 433
                         e2eeSupported: value
431 434
                     })),
432
-                'features_jigasi': (participant, value) =>
435
+                'features_jigasi': (participant: IJitsiParticipant, value: boolean) =>
433 436
                     store.dispatch(participantUpdated({
434 437
                         conference,
435 438
                         id: participant.getId(),
436 439
                         isJigasi: value
437 440
                     })),
438
-                'features_screen-sharing': (participant, value) => // eslint-disable-line no-unused-vars
441
+                // eslint-disable-next-line @typescript-eslint/no-unused-vars
442
+                'features_screen-sharing': (participant: IJitsiParticipant, value: string) =>
439 443
                     store.dispatch(participantUpdated({
440 444
                         conference,
441 445
                         id: participant.getId(),
442 446
                         features: { 'screen-sharing': true }
443 447
                     })),
444
-                'localRecording': (participant, value) =>
448
+                'localRecording': (participant: IJitsiParticipant, value: string) =>
445 449
                     _localRecordingUpdated(store, conference, participant.getId(), value),
446
-                'raisedHand': (participant, value) =>
450
+                'raisedHand': (participant: IJitsiParticipant, value: string) =>
447 451
                     _raiseHandUpdated(store, conference, participant.getId(), value),
448
-                'region': (participant, value) =>
452
+                'region': (participant: IJitsiParticipant, value: string) =>
449 453
                     store.dispatch(participantUpdated({
450 454
                         conference,
451 455
                         id: participant.getId(),
452 456
                         region: value
453 457
                     })),
454
-                'remoteControlSessionStatus': (participant, value) =>
458
+                'remoteControlSessionStatus': (participant: IJitsiParticipant, value: boolean) =>
455 459
                     store.dispatch(participantUpdated({
456 460
                         conference,
457 461
                         id: participant.getId(),
@@ -460,12 +464,12 @@ StateListenerRegistry.register(
460 464
             };
461 465
 
462 466
             // update properties for the participants that are already in the conference
463
-            conference.getParticipants().forEach(participant => {
467
+            conference.getParticipants().forEach((participant: any) => {
464 468
                 Object.keys(propertyHandlers).forEach(propertyName => {
465 469
                     const value = participant.getProperty(propertyName);
466 470
 
467 471
                     if (value !== undefined) {
468
-                        propertyHandlers[propertyName](participant, value);
472
+                        propertyHandlers[propertyName as keyof typeof propertyHandlers](participant, value);
469 473
                     }
470 474
                 });
471 475
             });
@@ -473,17 +477,17 @@ StateListenerRegistry.register(
473 477
             // We joined a conference
474 478
             conference.on(
475 479
                 JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
476
-                (participant, propertyName, oldValue, newValue) => {
480
+                (participant: IJitsiParticipant, propertyName: string, oldValue: string, newValue: string) => {
477 481
                     if (propertyHandlers.hasOwnProperty(propertyName)) {
478 482
                         propertyHandlers[propertyName](participant, newValue);
479 483
                     }
480 484
                 });
481 485
         } else {
482
-            const localParticipantId = getLocalParticipant(store.getState).id;
486
+            const localParticipantId = getLocalParticipant(store.getState)?.id;
483 487
 
484 488
             // We left the conference, the local participant must be updated.
485
-            _e2eeUpdated(store, conference, localParticipantId, false);
486
-            _raiseHandUpdated(store, conference, localParticipantId, 0);
489
+            _e2eeUpdated(store, conference, localParticipantId ?? '', false);
490
+            _raiseHandUpdated(store, conference, localParticipantId ?? '', 0);
487 491
         }
488 492
     }
489 493
 );
@@ -497,7 +501,8 @@ StateListenerRegistry.register(
497 501
  * @param {boolean} newValue - The new value of the E2EE enabled status.
498 502
  * @returns {void}
499 503
  */
500
-function _e2eeUpdated({ getState, dispatch }, conference, participantId, newValue) {
504
+function _e2eeUpdated({ getState, dispatch }: IStore, conference: IJitsiConference,
505
+        participantId: string, newValue: string | boolean) {
501 506
     const e2eeEnabled = newValue === 'true';
502 507
     const { e2ee = {} } = getState()['features/base/config'];
503 508
 
@@ -530,11 +535,12 @@ function _e2eeUpdated({ getState, dispatch }, conference, participantId, newValu
530 535
  * @private
531 536
  * @returns {Object} The value returned by {@code next(action)}.
532 537
  */
533
-function _localParticipantJoined({ getState, dispatch }, next, action) {
538
+function _localParticipantJoined({ getState, dispatch }: IStore, next: Function, action: any) {
534 539
     const result = next(action);
535 540
 
536 541
     const settings = getState()['features/base/settings'];
537 542
 
543
+    // @ts-ignore
538 544
     dispatch(localParticipantJoined({
539 545
         avatarURL: settings.avatarURL,
540 546
         email: settings.email,
@@ -555,7 +561,7 @@ function _localParticipantJoined({ getState, dispatch }, next, action) {
555 561
  * @private
556 562
  * @returns {Object} The value returned by {@code next(action)}.
557 563
  */
558
-function _localParticipantLeft({ dispatch }, next, action) {
564
+function _localParticipantLeft({ dispatch }: IStore, next: Function, action: any) {
559 565
     const result = next(action);
560 566
 
561 567
     dispatch(localParticipantLeft());
@@ -572,7 +578,7 @@ function _localParticipantLeft({ dispatch }, next, action) {
572 578
  * @private
573 579
  * @returns {void}
574 580
  */
575
-function _maybePlaySounds({ getState, dispatch }, action) {
581
+function _maybePlaySounds({ getState, dispatch }: IStore, action: any) {
576 582
     const state = getState();
577 583
     const { startAudioMuted } = state['features/base/config'];
578 584
     const { soundsParticipantJoined: joinSound, soundsParticipantLeft: leftSound } = state['features/base/settings'];
@@ -617,7 +623,7 @@ function _maybePlaySounds({ getState, dispatch }, action) {
617 623
  * @private
618 624
  * @returns {Object} The value returned by {@code next(action)}.
619 625
  */
620
-function _participantJoinedOrUpdated(store, next, action) {
626
+function _participantJoinedOrUpdated(store: IStore, next: Function, action: any) {
621 627
     const { dispatch, getState } = store;
622 628
     const { overwrittenNameList } = store.getState()['features/base/participants'];
623 629
     const { participant: {
@@ -639,7 +645,7 @@ function _participantJoinedOrUpdated(store, next, action) {
639 645
             const rHand = parseInt(raisedHandTimestamp, 10);
640 646
 
641 647
             // Send raisedHand signalling only if there is a change
642
-            if (conference && rHand !== getLocalParticipant(getState()).raisedHandTimestamp) {
648
+            if (conference && rHand !== getLocalParticipant(getState())?.raisedHandTimestamp) {
643 649
                 conference.setLocalParticipantProperty('raisedHand', rHand);
644 650
             }
645 651
         }
@@ -657,7 +663,7 @@ function _participantJoinedOrUpdated(store, next, action) {
657 663
 
658 664
             // Send localRecording signalling only if there is a change
659 665
             if (conference
660
-                && localRecording !== getLocalParticipant(getState()).localRecording) {
666
+                && localRecording !== getLocalParticipant(getState())?.localRecording) {
661 667
                 conference.setLocalParticipantProperty('localRecording', localRecording);
662 668
             }
663 669
         }
@@ -673,12 +679,12 @@ function _participantJoinedOrUpdated(store, next, action) {
673 679
         const { disableThirdPartyRequests } = getState()['features/base/config'];
674 680
 
675 681
         if (!disableThirdPartyRequests && (avatarURL || email || id || name)) {
676
-            const participantId = !id && local ? getLocalParticipant(getState()).id : id;
682
+            const participantId = !id && local ? getLocalParticipant(getState())?.id : id;
677 683
             const updatedParticipant = getParticipantById(getState(), participantId);
678 684
 
679
-            getFirstLoadableAvatarUrl(updatedParticipant, store)
680
-                .then(urlData => {
681
-                    dispatch(setLoadableAvatarUrl(participantId, urlData?.src, urlData?.isUsingCORS));
685
+            getFirstLoadableAvatarUrl(updatedParticipant ?? { id: '' }, store)
686
+                .then((urlData?: { isUsingCORS: boolean; src: string; }) => {
687
+                    dispatch(setLoadableAvatarUrl(participantId, urlData?.src ?? '', Boolean(urlData?.isUsingCORS)));
682 688
                 });
683 689
         }
684 690
     }
@@ -703,7 +709,8 @@ function _participantJoinedOrUpdated(store, next, action) {
703 709
  * @param {boolean} newValue - The new value of the local recording status.
704 710
  * @returns {void}
705 711
  */
706
-function _localRecordingUpdated({ dispatch, getState }, conference, participantId, newValue) {
712
+function _localRecordingUpdated({ dispatch, getState }: IStore, conference: IJitsiConference,
713
+        participantId: string, newValue: string) {
707 714
     const state = getState();
708 715
 
709 716
     dispatch(participantUpdated({
@@ -732,7 +739,8 @@ function _localRecordingUpdated({ dispatch, getState }, conference, participantI
732 739
  * @param {boolean} newValue - The new value of the raise hand status.
733 740
  * @returns {void}
734 741
  */
735
-function _raiseHandUpdated({ dispatch, getState }, conference, participantId, newValue) {
742
+function _raiseHandUpdated({ dispatch, getState }: IStore, conference: IJitsiConference,
743
+        participantId: string, newValue: string | number) {
736 744
     let raisedHandTimestamp;
737 745
 
738 746
     switch (newValue) {
@@ -744,7 +752,7 @@ function _raiseHandUpdated({ dispatch, getState }, conference, participantId, ne
744 752
         raisedHandTimestamp = Date.now();
745 753
         break;
746 754
     default:
747
-        raisedHandTimestamp = parseInt(newValue, 10);
755
+        raisedHandTimestamp = parseInt(`${newValue}`, 10);
748 756
     }
749 757
     const state = getState();
750 758
 
@@ -811,7 +819,7 @@ function _raiseHandUpdated({ dispatch, getState }, conference, participantId, ne
811 819
  * @private
812 820
  * @returns {void}
813 821
  */
814
-function _registerSounds({ dispatch }) {
822
+function _registerSounds({ dispatch }: IStore) {
815 823
     dispatch(
816 824
         registerSound(PARTICIPANT_JOINED_SOUND_ID, PARTICIPANT_JOINED_FILE));
817 825
     dispatch(registerSound(PARTICIPANT_LEFT_SOUND_ID, PARTICIPANT_LEFT_FILE));
@@ -824,7 +832,7 @@ function _registerSounds({ dispatch }) {
824 832
  * @private
825 833
  * @returns {void}
826 834
  */
827
-function _unregisterSounds({ dispatch }) {
835
+function _unregisterSounds({ dispatch }: IStore) {
828 836
     dispatch(unregisterSound(PARTICIPANT_JOINED_SOUND_ID));
829 837
     dispatch(unregisterSound(PARTICIPANT_LEFT_SOUND_ID));
830 838
 }

+ 5
- 0
react/features/base/participants/types.ts Visa fil

@@ -5,6 +5,7 @@ export interface Participant {
5 5
     connectionStatus?: string;
6 6
     displayName?: string;
7 7
     dominantSpeaker?: boolean;
8
+    e2eeEnabled?: boolean;
8 9
     e2eeSupported?: boolean;
9 10
     email?: string;
10 11
     features?: {
@@ -42,3 +43,7 @@ export interface LocalParticipant extends Participant {
42 43
     userSelectedMicDeviceId?: string;
43 44
     userSelectedMicDeviceLabel?: string;
44 45
 }
46
+
47
+export interface IJitsiParticipant {
48
+    getId: () => string;
49
+}

+ 4
- 4
react/features/base/sounds/actions.ts Visa fil

@@ -68,7 +68,7 @@ export function _removeAudioElement(soundId: string) {
68 68
  * which was used in {@link registerSound} to register the sound).
69 69
  * @returns {Function}
70 70
  */
71
-export function playSound(soundId: string): Object {
71
+export function playSound(soundId: string) {
72 72
     return (dispatch: Function, getState: Function) => {
73 73
         const disabledSounds = getDisabledSounds(getState());
74 74
 
@@ -103,7 +103,7 @@ export function playSound(soundId: string): Object {
103 103
  * }}
104 104
  */
105 105
 export function registerSound(
106
-        soundId: string, soundName: string, options: Object = {}): Object {
106
+        soundId: string, soundName: string, options: Object = {}) {
107 107
     return {
108 108
         type: REGISTER_SOUND,
109 109
         soundId,
@@ -122,7 +122,7 @@ export function registerSound(
122 122
  *     soundId: string
123 123
  * }}
124 124
  */
125
-export function stopSound(soundId: string): Object {
125
+export function stopSound(soundId: string) {
126 126
     return {
127 127
         type: STOP_SOUND,
128 128
         soundId
@@ -141,7 +141,7 @@ export function stopSound(soundId: string): Object {
141 141
  *     soundId: string
142 142
  * }}
143 143
  */
144
-export function unregisterSound(soundId: string): Object {
144
+export function unregisterSound(soundId: string) {
145 145
     return {
146 146
         type: UNREGISTER_SOUND,
147 147
         soundId

react/features/device-selection/functions.js → react/features/device-selection/functions.ts Visa fil

@@ -1,37 +1,37 @@
1
-// @flow
2
-
3
-import type { Dispatch } from 'redux';
4
-
1
+import { IStore } from '../app/types';
2
+import { IStateful } from '../base/app/types';
5 3
 import {
6 4
     addPendingDeviceRequest,
7
-    areDeviceLabelsInitialized,
8
-    getAudioOutputDeviceId,
9 5
     getAvailableDevices,
10
-    getDeviceIdByLabel,
11
-    groupDevicesByKind,
12 6
     setAudioInputDeviceAndUpdateSettings,
13 7
     setAudioOutputDevice,
14 8
     setVideoInputDeviceAndUpdateSettings
15
-} from '../base/devices';
9
+} from '../base/devices/actions';
10
+import {
11
+    areDeviceLabelsInitialized,
12
+    getAudioOutputDeviceId,
13
+    getDeviceIdByLabel,
14
+    groupDevicesByKind
15
+} from '../base/devices/functions';
16 16
 import { isIosMobileBrowser } from '../base/environment/utils';
17 17
 import JitsiMeetJS from '../base/lib-jitsi-meet';
18
-import { toState } from '../base/redux';
18
+import { toState } from '../base/redux/functions';
19 19
 import {
20 20
     getUserSelectedCameraDeviceId,
21 21
     getUserSelectedMicDeviceId,
22 22
     getUserSelectedOutputDeviceId
23
-} from '../base/settings';
23
+} from '../base/settings/functions.any';
24 24
 
25 25
 /**
26 26
  * Returns the properties for the device selection dialog from Redux state.
27 27
  *
28
- * @param {(Function|Object)} stateful -The (whole) redux state, or redux's
28
+ * @param {IStateful} stateful -The (whole) redux state, or redux's
29 29
  * {@code getState} function to be used to retrieve the state.
30 30
  * @param {boolean} isDisplayedOnWelcomePage - Indicates whether the device selection dialog is displayed on the
31 31
  * welcome page or not.
32 32
  * @returns {Object} - The properties for the device selection dialog.
33 33
  */
34
-export function getDeviceSelectionDialogProps(stateful: Object | Function, isDisplayedOnWelcomePage) {
34
+export function getDeviceSelectionDialogProps(stateful: IStateful, isDisplayedOnWelcomePage: boolean) {
35 35
     // On mobile Safari because of https://bugs.webkit.org/show_bug.cgi?id=179363#c30, the old track is stopped
36 36
     // by the browser when a new track is created for preview. That's why we are disabling all previews.
37 37
     const disablePreviews = isIosMobileBrowser();
@@ -96,9 +96,9 @@ export function getDeviceSelectionDialogProps(stateful: Object | Function, isDis
96 96
  * @returns {boolean} - True if the request has been processed and false otherwise.
97 97
  */
98 98
 export function processExternalDeviceRequest( // eslint-disable-line max-params
99
-        dispatch: Dispatch<any>,
100
-        getState: Function,
101
-        request: Object,
99
+        dispatch: IStore['dispatch'],
100
+        getState: IStore['getState'],
101
+        request: any,
102 102
         responseCallback: Function) {
103 103
     if (request.type !== 'devices') {
104 104
         return false;
@@ -119,10 +119,10 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
119 119
     case 'isMultipleAudioInputSupported':
120 120
         responseCallback(JitsiMeetJS.isMultipleAudioInputSupported());
121 121
         break;
122
-    case 'getCurrentDevices':
123
-        dispatch(getAvailableDevices()).then(devices => {
122
+    case 'getCurrentDevices': // @ts-ignore
123
+        dispatch(getAvailableDevices()).then((devices: MediaDeviceInfo[]) => {
124 124
             if (areDeviceLabelsInitialized(state)) {
125
-                const deviceDescriptions = {
125
+                const deviceDescriptions: any = {
126 126
                     audioInput: undefined,
127 127
                     audioOutput: undefined,
128 128
                     videoInput: undefined
@@ -164,8 +164,8 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
164 164
         });
165 165
 
166 166
         break;
167
-    case 'getAvailableDevices':
168
-        dispatch(getAvailableDevices()).then(devices => {
167
+    case 'getAvailableDevices': // @ts-ignore
168
+        dispatch(getAvailableDevices()).then((devices: MediaDeviceInfo[]) => {
169 169
             if (areDeviceLabelsInitialized(state)) {
170 170
                 responseCallback(groupDevicesByKind(devices));
171 171
             } else {

+ 3
- 0
react/features/notifications/actions.ts Visa fil

@@ -92,9 +92,12 @@ export function setNotificationsEnabled(enabled: boolean) {
92 92
 interface INotificationProps {
93 93
     appearance?: string;
94 94
     concatText?: boolean;
95
+    customActionHandler?: Function[];
96
+    customActionNameKey?: string[];
95 97
     description?: string;
96 98
     descriptionKey?: string;
97 99
     icon?: string;
100
+    title?: string;
98 101
     titleArguments?: {
99 102
         [key: string]: string;
100 103
     };

Laddar…
Avbryt
Spara