Преглед на файлове

ref: Convert some reducers to TS (#11886)

factor2
Robert Pintilii преди 3 години
родител
ревизия
c1e9724bba
No account linked to committer's email address

+ 7
- 2
react/features/app/types.ts Целия файл

12
 import { IJwtState } from '../base/jwt/reducer';
12
 import { IJwtState } from '../base/jwt/reducer';
13
 import { ILastNState } from '../base/lastn/reducer';
13
 import { ILastNState } from '../base/lastn/reducer';
14
 import { ILibJitsiMeetState } from '../base/lib-jitsi-meet/reducer';
14
 import { ILibJitsiMeetState } from '../base/lib-jitsi-meet/reducer';
15
+import { ILoggingState } from '../base/logging/reducer';
16
+import { IMediaState } from '../base/media/reducer';
17
+import { INetInfoState } from '../base/net-info/reducer';
15
 import { INoiseSuppressionState } from '../noise-suppression/reducer';
18
 import { INoiseSuppressionState } from '../noise-suppression/reducer';
16
 
19
 
17
-
18
 export interface IStore {
20
 export interface IStore {
19
     dispatch: Function,
21
     dispatch: Function,
20
     getState: Function
22
     getState: Function
35
     'features/base/jwt': IJwtState,
37
     'features/base/jwt': IJwtState,
36
     'features/base/known-domains': Array<string>,
38
     'features/base/known-domains': Array<string>,
37
     'features/base/lastn': ILastNState,
39
     'features/base/lastn': ILastNState,
38
-    'features/base/lib-jitsi-meet': ILibJitsiMeetState
40
+    'features/base/lib-jitsi-meet': ILibJitsiMeetState,
41
+    'features/base/logging': ILoggingState,
42
+    'features/base/media': IMediaState,
43
+    'features/base/net-info': INetInfoState,
39
     'features/noise-suppression': INoiseSuppressionState
44
     'features/noise-suppression': INoiseSuppressionState
40
 }
45
 }

react/features/base/logging/reducer.js → react/features/base/logging/reducer.ts Целия файл

1
-// @flow
2
-
3
-import { equals, ReducerRegistry, set } from '../redux';
1
+import ReducerRegistry from '../redux/ReducerRegistry';
2
+import { equals, set } from '../redux/functions';
4
 
3
 
5
 import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
4
 import { SET_LOG_COLLECTOR, SET_LOGGING_CONFIG } from './actionTypes';
6
 
5
 
38
     };
37
     };
39
 }
38
 }
40
 
39
 
40
+type LogLevel = 'trace' | 'log' | 'info' | 'warn' | 'error';
41
+
42
+interface LoggingLevel {
43
+    [key: string]: LogLevel;
44
+}
45
+
46
+export interface ILoggingState {
47
+    config: LoggingLevel & {
48
+        defaultLogLevel: LogLevel;
49
+        disableLogCollector?: boolean;
50
+    };
51
+    logCollector?: Object;
52
+}
53
+
41
 ReducerRegistry.register(
54
 ReducerRegistry.register(
42
     'features/base/logging',
55
     'features/base/logging',
43
-    (state = DEFAULT_STATE, action) => {
56
+    (state: ILoggingState = DEFAULT_STATE, action) => {
44
         switch (action.type) {
57
         switch (action.type) {
45
         case SET_LOGGING_CONFIG:
58
         case SET_LOGGING_CONFIG:
46
             return _setLoggingConfig(state, action);
59
             return _setLoggingConfig(state, action);
63
  * @returns {Object} The new state of the feature base/logging after the
76
  * @returns {Object} The new state of the feature base/logging after the
64
  * reduction of the specified action.
77
  * reduction of the specified action.
65
  */
78
  */
66
-function _setLoggingConfig(state, action) {
79
+function _setLoggingConfig(state: ILoggingState, action: any) {
67
     const config = {
80
     const config = {
68
         // The config of DEFAULT_STATE is the default configuration of the
81
         // The config of DEFAULT_STATE is the default configuration of the
69
         // feature base/logging.
82
         // feature base/logging.
91
  * @returns {Object} The new state of the feature base/logging after the
104
  * @returns {Object} The new state of the feature base/logging after the
92
  * reduction of the specified action.
105
  * reduction of the specified action.
93
  */
106
  */
94
-function _setLogCollector(state, action) {
107
+function _setLogCollector(state: ILoggingState, action: any) {
95
     return set(state, 'logCollector', action.logCollector);
108
     return set(state, 'logCollector', action.logCollector);
96
 }
109
 }

react/features/base/media/reducer.js → react/features/base/media/reducer.ts Целия файл

1
 import { combineReducers } from 'redux';
1
 import { combineReducers } from 'redux';
2
 
2
 
3
 import { CONFERENCE_FAILED, CONFERENCE_LEFT } from '../conference/actionTypes';
3
 import { CONFERENCE_FAILED, CONFERENCE_LEFT } from '../conference/actionTypes';
4
-import { ReducerRegistry } from '../redux';
4
+import ReducerRegistry from '../redux/ReducerRegistry';
5
 import { TRACK_REMOVED } from '../tracks/actionTypes';
5
 import { TRACK_REMOVED } from '../tracks/actionTypes';
6
 
6
 
7
 import {
7
 import {
49
  * @private
49
  * @private
50
  * @returns {AudioMediaState}
50
  * @returns {AudioMediaState}
51
  */
51
  */
52
-function _audio(state = _AUDIO_INITIAL_MEDIA_STATE, action) {
52
+function _audio(state: IAudioState = _AUDIO_INITIAL_MEDIA_STATE, action: any) {
53
     switch (action.type) {
53
     switch (action.type) {
54
     case SET_AUDIO_AVAILABLE:
54
     case SET_AUDIO_AVAILABLE:
55
         return {
55
         return {
103
  * @private
103
  * @private
104
  * @returns {ScreenshareMediaState}
104
  * @returns {ScreenshareMediaState}
105
  */
105
  */
106
-function _screenshare(state = _SCREENSHARE_INITIAL_MEDIA_STATE, action) {
106
+function _screenshare(state: IScreenshareState = _SCREENSHARE_INITIAL_MEDIA_STATE, action: any) {
107
     switch (action.type) {
107
     switch (action.type) {
108
     case SET_SCREENSHARE_MUTED:
108
     case SET_SCREENSHARE_MUTED:
109
         return {
109
         return {
161
  * @private
161
  * @private
162
  * @returns {VideoMediaState}
162
  * @returns {VideoMediaState}
163
  */
163
  */
164
-function _video(state = _VIDEO_INITIAL_MEDIA_STATE, action) {
164
+function _video(state: IVideoState = _VIDEO_INITIAL_MEDIA_STATE, action: any) {
165
     switch (action.type) {
165
     switch (action.type) {
166
     case CONFERENCE_FAILED:
166
     case CONFERENCE_FAILED:
167
     case CONFERENCE_LEFT:
167
     case CONFERENCE_LEFT:
216
     }
216
     }
217
 }
217
 }
218
 
218
 
219
+interface IAudioState {
220
+    available: boolean;
221
+    muted: boolean;
222
+    unmuteBlocked: boolean;
223
+}
224
+
225
+interface IScreenshareState {
226
+    available: boolean;
227
+    muted: number;
228
+    unmuteBlocked: boolean;
229
+}
230
+
231
+interface IVideoState {
232
+    available: boolean;
233
+    facingMode: string;
234
+    muted: number;
235
+    transforms: Object;
236
+    unmuteBlocked: boolean;
237
+}
238
+
239
+export interface IMediaState {
240
+    audio: IAudioState;
241
+    screenshare: IScreenshareState;
242
+    video: IVideoState;
243
+}
244
+
219
 /**
245
 /**
220
  * Listen for various actions related to media devices.
246
  * Listen for various actions related to media devices.
221
  *
247
  *
239
  * @private
265
  * @private
240
  * @returns {Object}
266
  * @returns {Object}
241
  */
267
  */
242
-function _clearAllVideoTransforms(state) {
268
+function _clearAllVideoTransforms(state: IVideoState) {
243
     return {
269
     return {
244
         ...state,
270
         ...state,
245
         transforms: _VIDEO_INITIAL_MEDIA_STATE.transforms
271
         transforms: _VIDEO_INITIAL_MEDIA_STATE.transforms
254
  * @private
280
  * @private
255
  * @returns {Object}
281
  * @returns {Object}
256
  */
282
  */
257
-function _storeVideoTransform(state, { streamId, transform }) {
283
+function _storeVideoTransform(state: IVideoState, { streamId, transform }: { streamId: string, transform: string }) {
258
     return {
284
     return {
259
         ...state,
285
         ...state,
260
         transforms: {
286
         transforms: {
273
  * @private
299
  * @private
274
  * @returns {Object}
300
  * @returns {Object}
275
  */
301
  */
276
-function _trackRemoved(state, { track: { jitsiTrack } }) {
302
+function _trackRemoved(state: IVideoState, { track: { jitsiTrack } } : {track: {jitsiTrack: any}}) {
277
     if (jitsiTrack) {
303
     if (jitsiTrack) {
278
         const streamId = jitsiTrack.getStreamId();
304
         const streamId = jitsiTrack.getStreamId();
279
 
305
 
280
         if (streamId && streamId in state.transforms) {
306
         if (streamId && streamId in state.transforms) {
281
-            const nextTransforms = {
307
+            const nextTransforms: any = {
282
                 ...state.transforms
308
                 ...state.transforms
283
             };
309
             };
284
 
310
 

react/features/base/net-info/constants.js → react/features/base/net-info/constants.ts Целия файл


react/features/base/net-info/reducer.js → react/features/base/net-info/reducer.ts Целия файл

1
-// @flow
2
-import { assign, ReducerRegistry } from '../redux';
1
+import { NetInfoCellularGeneration, NetInfoStateType } from '@react-native-community/netinfo';
2
+
3
+import ReducerRegistry from '../redux/ReducerRegistry';
4
+import { assign } from '../redux/functions';
3
 
5
 
4
 import { SET_NETWORK_INFO, _STORE_NETWORK_INFO_CLEANUP } from './actionTypes';
6
 import { SET_NETWORK_INFO, _STORE_NETWORK_INFO_CLEANUP } from './actionTypes';
5
 import { STORE_NAME } from './constants';
7
 import { STORE_NAME } from './constants';
8
     isOnline: true
10
     isOnline: true
9
 };
11
 };
10
 
12
 
13
+export interface INetInfoState {
14
+    _cleanup?: Function;
15
+    cellularGeneration?: NetInfoCellularGeneration;
16
+    details?: Object;
17
+    isOnline?: boolean;
18
+    networkType?: NetInfoStateType;
19
+}
20
+
11
 /**
21
 /**
12
  * The base/net-info feature's reducer.
22
  * The base/net-info feature's reducer.
13
  */
23
  */
14
-ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
24
+ReducerRegistry.register(STORE_NAME, (state: INetInfoState = DEFAULT_STATE, action) => {
15
     switch (action.type) {
25
     switch (action.type) {
16
     case SET_NETWORK_INFO:
26
     case SET_NETWORK_INFO:
17
         return assign(state, {
27
         return assign(state, {

+ 1
- 2
react/features/noise-suppression/reducer.ts Целия файл

1
-// @ts-ignore
2
-import { ReducerRegistry } from '../base/redux';
1
+import ReducerRegistry from '../base/redux/ReducerRegistry';
3
 
2
 
4
 import {
3
 import {
5
     SET_NOISE_SUPPRESSION_ENABLED
4
     SET_NOISE_SUPPRESSION_ENABLED

Loading…
Отказ
Запис