瀏覽代碼

ref(TS) Convert some features to TS (#12425)

factor2
Robert Pintilii 2 年之前
父節點
當前提交
0b48e55a35
沒有連結到貢獻者的電子郵件帳戶。

+ 1
- 0
react/features/base/conference/reducer.ts 查看文件

@@ -70,6 +70,7 @@ export interface IJitsiConference {
70 70
     sendFeedback: Function;
71 71
     sendLobbyMessage: Function;
72 72
     sessionId: string;
73
+    setDesktopSharingFrameRate: Function;
73 74
     setDisplayName: Function;
74 75
     setLocalParticipantProperty: Function;
75 76
     setSubject: Function;

react/features/screen-share/actions.js → react/features/screen-share/actions.ts 查看文件

@@ -1,16 +1,15 @@
1
-// @flow
2
-
1
+import { IStore } from '../app/types';
3 2
 import { openDialog } from '../base/dialog/actions';
4 3
 import { browser } from '../base/lib-jitsi-meet';
5
-import { shouldHideShareAudioHelper } from '../base/settings';
6
-import { toggleScreensharing } from '../base/tracks';
4
+import { shouldHideShareAudioHelper } from '../base/settings/functions';
5
+import { toggleScreensharing } from '../base/tracks/actions';
7 6
 
8 7
 import {
9 8
     SET_SCREENSHARE_CAPTURE_FRAME_RATE,
10 9
     SET_SCREENSHARE_TRACKS,
11 10
     SET_SCREEN_AUDIO_SHARE_STATE
12 11
 } from './actionTypes';
13
-import { ShareAudioDialog } from './components';
12
+import ShareAudioDialog from './components/ShareAudioDialog';
14 13
 import ShareMediaWarningDialog from './components/ShareScreenWarningDialog';
15 14
 import { isAudioOnlySharing, isScreenVideoShared } from './functions';
16 15
 
@@ -55,7 +54,7 @@ export function setScreenshareFramerate(captureFrameRate: number) {
55 54
  *      desktopAudioTrack: JitsiTrack
56 55
  * }}
57 56
  */
58
-export function setScreenshareAudioTrack(desktopAudioTrack) {
57
+export function setScreenshareAudioTrack(desktopAudioTrack: any) {
59 58
     return {
60 59
         type: SET_SCREENSHARE_TRACKS,
61 60
         desktopAudioTrack
@@ -69,12 +68,12 @@ export function setScreenshareAudioTrack(desktopAudioTrack) {
69 68
  * @returns {void}
70 69
  */
71 70
 export function startAudioScreenShareFlow() {
72
-    return (dispatch: Object => Object, getState: () => any) => {
71
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
73 72
         const state = getState();
74 73
         const audioOnlySharing = isAudioOnlySharing(state);
75 74
 
76 75
         // If we're already in a normal screen sharing session, warn the user.
77
-        if (isScreenVideoShared(state)) {
76
+        if (isScreenVideoShared(state)) { // @ts-ignore
78 77
             dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: true }));
79 78
 
80 79
             return;
@@ -92,6 +91,7 @@ export function startAudioScreenShareFlow() {
92 91
             return;
93 92
         }
94 93
 
94
+        // @ts-ignore
95 95
         dispatch(openDialog(ShareAudioDialog));
96 96
     };
97 97
 }
@@ -104,12 +104,12 @@ export function startAudioScreenShareFlow() {
104 104
  * @returns {void}
105 105
  */
106 106
 export function startScreenShareFlow(enabled: boolean) {
107
-    return (dispatch: Object => Object, getState: () => any) => {
107
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
108 108
         const state = getState();
109 109
         const audioOnlySharing = isAudioOnlySharing(state);
110 110
 
111 111
         // If we're in an audio screen sharing session, warn the user.
112
-        if (audioOnlySharing) {
112
+        if (audioOnlySharing) { // @ts-ignore
113 113
             dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: false }));
114 114
 
115 115
             return;

react/features/screen-share/logger.js → react/features/screen-share/logger.ts 查看文件

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

react/features/screen-share/middleware.js → react/features/screen-share/middleware.ts 查看文件

@@ -1,14 +1,11 @@
1
-// @flow
2
-
3
-import { CONFERENCE_JOINED } from '../base/conference';
4
-import { MEDIA_TYPE } from '../base/media';
5
-import { MiddlewareRegistry } from '../base/redux';
1
+import { IStore } from '../app/types';
2
+import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
3
+import { MEDIA_TYPE } from '../base/media/constants';
4
+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
6 5
 
7 6
 import { SET_SCREENSHARE_CAPTURE_FRAME_RATE, SET_SCREEN_AUDIO_SHARE_STATE } from './actionTypes';
8 7
 import logger from './logger';
9 8
 
10
-declare var APP: Object;
11
-
12 9
 /**
13 10
  * Implements the middleware of the feature screen-share.
14 11
  *
@@ -57,7 +54,7 @@ MiddlewareRegistry.register(store => next => action => {
57 54
  * @private
58 55
  * @returns {void}
59 56
  */
60
-function _setScreenshareCaptureFps(store, frameRate) {
57
+function _setScreenshareCaptureFps(store: IStore, frameRate?: number) {
61 58
     const state = store.getState();
62 59
     const { conference } = state['features/base/conference'];
63 60
     const { captureFrameRate } = state['features/screen-share'];

react/features/settings/actions.js → react/features/settings/actions.ts 查看文件

@@ -1,21 +1,22 @@
1
-// @flow
2 1
 import { batch } from 'react-redux';
3 2
 
4
-
3
+import { IStore } from '../app/types';
5 4
 import {
6 5
     setFollowMe,
7 6
     setStartMutedPolicy,
8 7
     setStartReactionsMuted
9
-} from '../base/conference';
10
-import { openDialog } from '../base/dialog';
11
-import { i18next } from '../base/i18n';
12
-import { updateSettings } from '../base/settings';
8
+} from '../base/conference/actions';
9
+import { openDialog } from '../base/dialog/actions';
10
+import i18next from '../base/i18n/i18next';
11
+import { updateSettings } from '../base/settings/actions';
13 12
 import { setScreenshareFramerate } from '../screen-share/actions';
14 13
 
15 14
 import {
16 15
     SET_AUDIO_SETTINGS_VISIBILITY,
17 16
     SET_VIDEO_SETTINGS_VISIBILITY
18 17
 } from './actionTypes';
18
+// eslint-disable-next-line lines-around-comment
19
+// @ts-ignore
19 20
 import { LogoutDialog, SettingsDialog } from './components';
20 21
 import {
21 22
     getModeratorTabProps,
@@ -24,8 +25,6 @@ import {
24 25
     getSoundsTabProps
25 26
 } from './functions';
26 27
 
27
-declare var APP: Object;
28
-
29 28
 /**
30 29
  * Opens {@code LogoutDialog}.
31 30
  *
@@ -46,7 +45,7 @@ export function openLogoutDialog(onLogout: Function) {
46 45
  * welcome page or not.
47 46
  * @returns {Function}
48 47
  */
49
-export function openSettingsDialog(defaultTab: string, isDisplayedOnWelcomePage: boolean) {
48
+export function openSettingsDialog(defaultTab: string, isDisplayedOnWelcomePage?: boolean) {
50 49
     return openDialog(SettingsDialog, {
51 50
         defaultTab,
52 51
         isDisplayedOnWelcomePage
@@ -85,8 +84,8 @@ function setVideoSettingsVisibility(value: boolean) {
85 84
  * @param {Object} newState - The new settings.
86 85
  * @returns {Function}
87 86
  */
88
-export function submitMoreTab(newState: Object): Function {
89
-    return (dispatch, getState) => {
87
+export function submitMoreTab(newState: any) {
88
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
90 89
         const currentState = getMoreTabProps(getState());
91 90
 
92 91
         const showPrejoinPage = newState.showPrejoinPage;
@@ -134,8 +133,8 @@ export function submitMoreTab(newState: Object): Function {
134 133
  * @param {Object} newState - The new settings.
135 134
  * @returns {Function}
136 135
  */
137
-export function submitModeratorTab(newState: Object): Function {
138
-    return (dispatch, getState) => {
136
+export function submitModeratorTab(newState: any) {
137
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
139 138
         const currentState = getModeratorTabProps(getState());
140 139
 
141 140
         if (newState.followMeEnabled !== currentState.followMeEnabled) {
@@ -164,8 +163,8 @@ export function submitModeratorTab(newState: Object): Function {
164 163
  * @param {Object} newState - The new settings.
165 164
  * @returns {Function}
166 165
  */
167
-export function submitProfileTab(newState: Object): Function {
168
-    return (dispatch, getState) => {
166
+export function submitProfileTab(newState: any) {
167
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
169 168
         const currentState = getProfileTabProps(getState());
170 169
 
171 170
         if (newState.displayName !== currentState.displayName) {
@@ -184,8 +183,8 @@ export function submitProfileTab(newState: Object): Function {
184 183
  * @param {Object} newState - The new settings.
185 184
  * @returns {Function}
186 185
  */
187
-export function submitSoundsTab(newState: Object): Function {
188
-    return (dispatch, getState) => {
186
+export function submitSoundsTab(newState: any) {
187
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
189 188
         const currentState = getSoundsTabProps(getState());
190 189
         const shouldNotUpdateReactionSounds = getModeratorTabProps(getState()).startReactionsMuted;
191 190
         const shouldUpdate = (newState.soundsIncomingMessage !== currentState.soundsIncomingMessage)
@@ -219,7 +218,7 @@ export function submitSoundsTab(newState: Object): Function {
219 218
  * @returns {void}
220 219
  */
221 220
 export function toggleAudioSettings() {
222
-    return (dispatch: Function, getState: Function) => {
221
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
223 222
         const value = getState()['features/settings'].audioSettingsVisible;
224 223
 
225 224
         dispatch(setAudioSettingsVisibility(!value));
@@ -232,7 +231,7 @@ export function toggleAudioSettings() {
232 231
  * @returns {void}
233 232
  */
234 233
 export function toggleVideoSettings() {
235
-    return (dispatch: Function, getState: Function) => {
234
+    return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
236 235
         const value = getState()['features/settings'].videoSettingsVisible;
237 236
 
238 237
         dispatch(setVideoSettingsVisibility(!value));

react/features/settings/functions.js → react/features/settings/functions.ts 查看文件

@@ -1,25 +1,27 @@
1
-// @flow
2
-
3
-import { isNameReadOnly } from '../base/config';
4
-import { SERVER_URL_CHANGE_ENABLED, getFeatureFlag } from '../base/flags';
5
-import { DEFAULT_LANGUAGE, LANGUAGES, i18next } from '../base/i18n';
1
+/* eslint-disable lines-around-comment */
2
+import { IReduxState } from '../app/types';
3
+import { IStateful } from '../base/app/types';
4
+import { isNameReadOnly } from '../base/config/functions';
5
+import { SERVER_URL_CHANGE_ENABLED } from '../base/flags/constants';
6
+import { getFeatureFlag } from '../base/flags/functions';
7
+import i18next, { DEFAULT_LANGUAGE, LANGUAGES } from '../base/i18n/i18next';
6 8
 import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
7 9
 import {
8 10
     getLocalParticipant,
9 11
     isLocalParticipantModerator
10
-} from '../base/participants';
11
-import { toState } from '../base/redux';
12
-import { getHideSelfView } from '../base/settings';
13
-import { parseStandardURIString } from '../base/util';
12
+} from '../base/participants/functions';
13
+import { toState } from '../base/redux/functions';
14
+import { getHideSelfView } from '../base/settings/functions';
15
+import { parseStandardURIString } from '../base/util/uri';
16
+// @ts-ignore
14 17
 import { isStageFilmstripEnabled } from '../filmstrip/functions';
18
+// @ts-ignore
15 19
 import { isFollowMeActive } from '../follow-me';
16 20
 import { getParticipantsPaneConfig } from '../participants-pane/functions';
17 21
 import { isReactionsEnabled } from '../reactions/functions.any';
18 22
 
19 23
 import { SS_DEFAULT_FRAME_RATE, SS_SUPPORTED_FRAMERATES } from './constants';
20 24
 
21
-declare var interfaceConfig: Object;
22
-
23 25
 /**
24 26
  * Used for web. Indicates if the setting section is enabled.
25 27
  *
@@ -39,7 +41,7 @@ export function isSettingEnabled(settingName: string) {
39 41
  * {@code getState} function to be used to retrieve the state.
40 42
  * @returns {boolean} True to indicate that user can change Server URL, false otherwise.
41 43
  */
42
-export function isServerURLChangeEnabled(stateful: Object | Function) {
44
+export function isServerURLChangeEnabled(stateful: IStateful) {
43 45
     const state = toState(stateful);
44 46
     const flag = getFeatureFlag(state, SERVER_URL_CHANGE_ENABLED, true);
45 47
 
@@ -88,11 +90,15 @@ export function normalizeUserInputURL(url: string) {
88 90
  * {@code getState} function to be used to retrieve the state.
89 91
  * @returns {Object} - The section of notifications to be configured.
90 92
  */
91
-export function getNotificationsMap(stateful: Object | Function) {
93
+export function getNotificationsMap(stateful: IStateful) {
92 94
     const state = toState(stateful);
93 95
     const { notifications } = state['features/base/config'];
94 96
     const { userSelectedNotifications } = state['features/base/settings'];
95 97
 
98
+    if (!userSelectedNotifications) {
99
+        return {};
100
+    }
101
+
96 102
     return Object.keys(userSelectedNotifications)
97 103
         .filter(key => !notifications || notifications.includes(key))
98 104
         .reduce((notificationsMap, key) => {
@@ -111,7 +117,7 @@ export function getNotificationsMap(stateful: Object | Function) {
111 117
  * {@code getState} function to be used to retrieve the state.
112 118
  * @returns {Object} - The properties for the "More" tab from settings dialog.
113 119
  */
114
-export function getMoreTabProps(stateful: Object | Function) {
120
+export function getMoreTabProps(stateful: IStateful) {
115 121
     const state = toState(stateful);
116 122
     const framerate = state['features/screen-share'].captureFrameRate ?? SS_DEFAULT_FRAME_RATE;
117 123
     const language = i18next.language || DEFAULT_LANGUAGE;
@@ -147,7 +153,7 @@ export function getMoreTabProps(stateful: Object | Function) {
147 153
  * {@code getState} function to be used to retrieve the state.
148 154
  * @returns {Object} - The properties for the "More" tab from settings dialog.
149 155
  */
150
-export function getModeratorTabProps(stateful: Object | Function) {
156
+export function getModeratorTabProps(stateful: IStateful) {
151 157
     const state = toState(stateful);
152 158
     const {
153 159
         conference,
@@ -179,7 +185,7 @@ export function getModeratorTabProps(stateful: Object | Function) {
179 185
  * {@code getState} function to be used to retrieve the state.
180 186
  * @returns {boolean} True to indicate that moderator tab should be visible, false otherwise.
181 187
  */
182
-export function shouldShowModeratorSettings(stateful: Object | Function) {
188
+export function shouldShowModeratorSettings(stateful: IStateful) {
183 189
     const state = toState(stateful);
184 190
     const { hideModeratorSettingsTab } = getParticipantsPaneConfig(state);
185 191
     const hasModeratorRights = Boolean(isSettingEnabled('moderator') && isLocalParticipantModerator(state));
@@ -196,7 +202,7 @@ export function shouldShowModeratorSettings(stateful: Object | Function) {
196 202
  * @returns {Object} - The properties for the "Profile" tab from settings
197 203
  * dialog.
198 204
  */
199
-export function getProfileTabProps(stateful: Object | Function) {
205
+export function getProfileTabProps(stateful: IStateful) {
200 206
     const state = toState(stateful);
201 207
     const {
202 208
         authEnabled,
@@ -209,8 +215,8 @@ export function getProfileTabProps(stateful: Object | Function) {
209 215
     return {
210 216
         authEnabled: Boolean(conference && authEnabled),
211 217
         authLogin,
212
-        displayName: localParticipant.name,
213
-        email: localParticipant.email,
218
+        displayName: localParticipant?.name,
219
+        email: localParticipant?.email,
214 220
         readOnlyName: isNameReadOnly(state),
215 221
         hideEmailInSettings
216 222
     };
@@ -225,7 +231,7 @@ export function getProfileTabProps(stateful: Object | Function) {
225 231
  * @returns {Object} - The properties for the "Sounds" tab from settings
226 232
  * dialog.
227 233
  */
228
-export function getSoundsTabProps(stateful: Object | Function) {
234
+export function getSoundsTabProps(stateful: IStateful) {
229 235
     const state = toState(stateful);
230 236
     const {
231 237
         soundsIncomingMessage,
@@ -259,21 +265,21 @@ export function getSoundsTabProps(stateful: Object | Function) {
259 265
  *
260 266
  * @returns {Promise<Object[]>}
261 267
  */
262
-export function createLocalVideoTracks(ids: string[], timeout: ?number) {
268
+export function createLocalVideoTracks(ids: string[], timeout?: number) {
263 269
     return Promise.all(ids.map(deviceId => createLocalTrack('video', deviceId, timeout)
264
-                   .then(jitsiTrack => {
265
-                       return {
266
-                           jitsiTrack,
267
-                           deviceId
268
-                       };
269
-                   })
270
-                   .catch(() => {
271
-                       return {
272
-                           jitsiTrack: null,
273
-                           deviceId,
274
-                           error: 'deviceSelection.previewUnavailable'
275
-                       };
276
-                   })));
270
+                    .then((jitsiTrack: any) => {
271
+                        return {
272
+                            jitsiTrack,
273
+                            deviceId
274
+                        };
275
+                    })
276
+                    .catch(() => {
277
+                        return {
278
+                            jitsiTrack: null,
279
+                            deviceId,
280
+                            error: 'deviceSelection.previewUnavailable'
281
+                        };
282
+                    })));
277 283
 }
278 284
 
279 285
 
@@ -290,7 +296,7 @@ export function createLocalVideoTracks(ids: string[], timeout: ?number) {
290 296
  *   label: string
291 297
  * }[]>}
292 298
  */
293
-export function createLocalAudioTracks(devices: Object[], timeout: ?number) {
299
+export function createLocalAudioTracks(devices: MediaDeviceInfo[], timeout?: number) {
294 300
     return Promise.all(
295 301
         devices.map(async ({ deviceId, label }) => {
296 302
             let jitsiTrack = null;
@@ -317,7 +323,7 @@ export function createLocalAudioTracks(devices: Object[], timeout: ?number) {
317 323
  * @param {Object} state - The state of the application.
318 324
  * @returns {boolean}
319 325
  */
320
-export function getAudioSettingsVisibility(state: Object) {
326
+export function getAudioSettingsVisibility(state: IReduxState) {
321 327
     return state['features/settings'].audioSettingsVisible;
322 328
 }
323 329
 
@@ -327,6 +333,6 @@ export function getAudioSettingsVisibility(state: Object) {
327 333
  * @param {Object} state - The state of the application.
328 334
  * @returns {boolean}
329 335
  */
330
-export function getVideoSettingsVisibility(state: Object) {
336
+export function getVideoSettingsVisibility(state: IReduxState) {
331 337
     return state['features/settings'].videoSettingsVisible;
332 338
 }

react/features/settings/logger.js → react/features/settings/logger.ts 查看文件

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

react/features/settings/middleware.web.js → react/features/settings/middleware.web.ts 查看文件

@@ -1,6 +1,8 @@
1
-import { MiddlewareRegistry } from '../base/redux';
2
-import { SETTINGS_UPDATED, getHideSelfView } from '../base/settings';
3
-import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE, showNotification } from '../notifications';
1
+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
2
+import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
3
+import { getHideSelfView } from '../base/settings/functions';
4
+import { showNotification } from '../notifications/actions';
5
+import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
4 6
 
5 7
 import { openSettingsDialog } from './actions';
6 8
 import { SETTINGS_TABS } from './constants';

Loading…
取消
儲存