瀏覽代碼

ref(TS) Convert some Abstract classes to TS (#13117)

factor2
Robert Pintilii 2 年之前
父節點
當前提交
b942ce9378
No account linked to committer's email address

react/features/connection-indicator/components/AbstractConnectionIndicator.js → react/features/connection-indicator/components/AbstractConnectionIndicator.ts 查看文件

@@ -1,7 +1,6 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
4 2
 
3
+import { IReduxState } from '../../app/types';
5 4
 import { getVirtualScreenshareParticipantOwnerId } from '../../base/participants/functions';
6 5
 import statsEmitter from '../statsEmitter';
7 6
 
@@ -18,49 +17,51 @@ export const INDICATOR_DISPLAY_THRESHOLD = 30;
18 17
 /**
19 18
  * The type of the React {@code Component} props of {@link ConnectionIndicator}.
20 19
  */
21
-export type Props = {
20
+export interface IProps {
22 21
 
23 22
     /**
24 23
      * How long the connection indicator should remain displayed before hiding.
25 24
      */
26
-    _autoHideTimeout: number,
25
+    _autoHideTimeout: number;
27 26
 
28 27
     /**
29 28
      * Whether or not the statistics are for screen share.
30 29
      */
31
-    _isVirtualScreenshareParticipant: boolean,
30
+    _isVirtualScreenshareParticipant: boolean;
32 31
 
33 32
     /**
34
-     * The ID of the participant associated with the displayed connection indication and
35
-     * stats.
33
+     * Custom icon style.
36 34
      */
37
-    participantId: string,
35
+    iconStyle?: Object;
38 36
 
39 37
     /**
40
-     * Custom icon style.
38
+     * The ID of the participant associated with the displayed connection indication and
39
+     * stats.
41 40
      */
42
-    iconStyle?: Object
43
-};
41
+    participantId: string;
42
+}
44 43
 
45 44
 /**
46 45
  * The type of the React {@code Component} state of {@link ConnectionIndicator}.
47 46
  */
48
-export type State = {
47
+export interface IState {
49 48
 
50 49
     /**
51 50
      * Whether or not a CSS class should be applied to the root for hiding the
52 51
      * connection indicator. By default the indicator should start out hidden
53 52
      * because the current connection status is not known at mount.
54 53
      */
55
-    showIndicator: boolean,
54
+    showIndicator: boolean;
56 55
 
57 56
     /**
58 57
      * Cache of the stats received from subscribing to stats emitting. The keys
59 58
      * should be the name of the stat. With each stat update, updates stats are
60 59
      * mixed in with cached stats and a new stats object is set in state.
61 60
      */
62
-    stats: Object
63
-};
61
+    stats: {
62
+        percent?: number;
63
+    };
64
+}
64 65
 
65 66
 /**
66 67
  * Implements a React {@link Component} which displays the current connection
@@ -68,11 +69,11 @@ export type State = {
68 69
  *
69 70
  * @augments {Component}
70 71
  */
71
-class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
72
+class AbstractConnectionIndicator<P extends IProps, S extends IState> extends Component<P, S> {
72 73
     /**
73 74
      * The timeout for automatically hiding the indicator.
74 75
      */
75
-    autoHideTimeout: ?TimeoutID;
76
+    autoHideTimeout: number | undefined;
76 77
 
77 78
     /**
78 79
      * Initializes a new {@code ConnectionIndicator} instance.
@@ -103,7 +104,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
103 104
      * @inheritdoc
104 105
      * returns {void}
105 106
      */
106
-    componentDidUpdate(prevProps: Props) {
107
+    componentDidUpdate(prevProps: IProps) {
107 108
         const prevParticipantId = this._getRealParticipantId(prevProps);
108 109
         const participantId = this._getRealParticipantId(this.props);
109 110
 
@@ -123,7 +124,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
123 124
     componentWillUnmount() {
124 125
         statsEmitter.unsubscribeToClientStats(this._getRealParticipantId(this.props), this._onStatsUpdated);
125 126
 
126
-        clearTimeout(this.autoHideTimeout);
127
+        clearTimeout(this.autoHideTimeout ?? 0);
127 128
     }
128 129
 
129 130
     /**
@@ -132,7 +133,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
132 133
      * @param {Props} props - The props where to extract the data from.
133 134
      * @returns {string | undefined } The resolved participant ID.
134 135
      */
135
-    _getRealParticipantId(props: Props) {
136
+    _getRealParticipantId(props: IProps) {
136 137
         if (props._isVirtualScreenshareParticipant) {
137 138
             return getVirtualScreenshareParticipantOwnerId(props.participantId);
138 139
         }
@@ -140,8 +141,6 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
140 141
         return props.participantId;
141 142
     }
142 143
 
143
-    _onStatsUpdated: (Object) => void;
144
-
145 144
     /**
146 145
      * Callback invoked when new connection stats associated with the passed in
147 146
      * user ID are available. Will update the component's display of current
@@ -151,7 +150,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
151 150
      * @private
152 151
      * @returns {void}
153 152
      */
154
-    _onStatsUpdated(stats = {}) {
153
+    _onStatsUpdated(stats = { connectionQuality: undefined }) {
155 154
         // Rely on React to batch setState actions.
156 155
         const { connectionQuality } = stats;
157 156
         const newPercentageState = typeof connectionQuality === 'undefined'
@@ -166,7 +165,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
166 165
             stats: newStats
167 166
         });
168 167
 
169
-        this._updateIndicatorAutoHide(newStats.percent);
168
+        this._updateIndicatorAutoHide(newStats.percent ?? 0);
170 169
     }
171 170
 
172 171
     /**
@@ -177,9 +176,9 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
177 176
      * @private
178 177
      * @returns {void}
179 178
      */
180
-    _updateIndicatorAutoHide(percent) {
179
+    _updateIndicatorAutoHide(percent: number) {
181 180
         if (percent < INDICATOR_DISPLAY_THRESHOLD) {
182
-            clearTimeout(this.autoHideTimeout);
181
+            clearTimeout(this.autoHideTimeout ?? 0);
183 182
             this.autoHideTimeout = undefined;
184 183
 
185 184
             this.setState({
@@ -190,7 +189,7 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
190 189
             // is needed if the percent is below the threshold and there is an
191 190
             // autoHideTimeout set.
192 191
         } else {
193
-            this.autoHideTimeout = setTimeout(() => {
192
+            this.autoHideTimeout = window.setTimeout(() => {
194 193
                 this.setState({
195 194
                     showIndicator: false
196 195
                 });
@@ -205,9 +204,9 @@ class AbstractConnectionIndicator<P: Props, S: State> extends Component<P, S> {
205 204
  *
206 205
  * @param {Object} state - The Redux state.
207 206
  * @private
208
- * @returns {Props}
207
+ * @returns {IProps}
209 208
  */
210
-export function mapStateToProps(state: Object) {
209
+export function mapStateToProps(state: IReduxState) {
211 210
     return {
212 211
         _autoHideTimeout: state['features/base/config'].connectionIndicators?.autoHideTimeout ?? defaultAutoHideTimeout
213 212
     };

+ 1
- 2
react/features/connection-indicator/components/native/ConnectionIndicator.tsx 查看文件

@@ -24,9 +24,8 @@ import {
24 24
     isTrackStreamingStatusInterrupted
25 25
 } from '../../functions';
26 26
 import AbstractConnectionIndicator, {
27
-    type Props as AbstractProps,
27
+    IProps as AbstractProps,
28 28
     mapStateToProps as _abstractMapStateToProps
29
-    // @ts-ignore
30 29
 } from '../AbstractConnectionIndicator';
31 30
 
32 31
 import {

+ 29
- 34
react/features/connection-indicator/components/web/ConnectionIndicator.tsx 查看文件

@@ -18,17 +18,16 @@ import {
18 18
     getTrackByMediaTypeAndParticipant,
19 19
     getVirtualScreenshareParticipantTrack
20 20
 } from '../../../base/tracks/functions';
21
+import { ITrack } from '../../../base/tracks/types';
21 22
 import {
22 23
     isTrackStreamingStatusInactive,
23 24
     isTrackStreamingStatusInterrupted
24 25
 } from '../../functions';
25 26
 import AbstractConnectionIndicator, {
26
-    type Props as AbstractProps,
27
-    type State as AbstractState,
27
+    IProps as AbstractProps,
28
+    IState as AbstractState,
28 29
     INDICATOR_DISPLAY_THRESHOLD,
29 30
     mapStateToProps as _abstractMapStateToProps
30
-
31
-    // @ts-ignore
32 31
 } from '../AbstractConnectionIndicator';
33 32
 
34 33
 // @ts-ignore
@@ -77,18 +76,33 @@ const QUALITY_TO_WIDTH: Array<{
77 76
 /**
78 77
  * The type of the React {@code Component} props of {@link ConnectionIndicator}.
79 78
  */
80
-type Props = AbstractProps & WithTranslation & {
79
+interface IProps extends AbstractProps, WithTranslation {
81 80
 
82 81
     /**
83 82
      * Disable/enable inactive indicator.
84 83
      */
85 84
     _connectionIndicatorInactiveDisabled: boolean;
86 85
 
86
+    /**
87
+     * Whether the connection status is inactive.
88
+     */
89
+    _isConnectionStatusInactive: boolean;
90
+
91
+    /**
92
+     * Whether the connection status is interrupted.
93
+     */
94
+    _isConnectionStatusInterrupted?: boolean;
95
+
87 96
     /**
88 97
      * Whether the indicator popover is disabled.
89 98
      */
90 99
     _popoverDisabled: boolean;
91 100
 
101
+    /**
102
+     * The participant's video track;.
103
+     */
104
+    _videoTrack?: ITrack;
105
+
92 106
     /**
93 107
      * Whether or not the component should ignore setting a visibility class for
94 108
      * hiding the component when the connection quality is not strong.
@@ -98,7 +112,7 @@ type Props = AbstractProps & WithTranslation & {
98 112
     /**
99 113
      * The audio SSRC of this client.
100 114
      */
101
-    audioSsrc: number;
115
+    audioSsrc?: number;
102 116
 
103 117
     /**
104 118
      * An object containing the CSS classes.
@@ -126,12 +140,12 @@ type Props = AbstractProps & WithTranslation & {
126 140
      * should display.
127 141
      */
128 142
     statsPopoverPosition: string;
129
-};
143
+}
130 144
 
131 145
 interface IState extends AbstractState {
132 146
 
133 147
     /**
134
-     * Whether popover is ivisible or not.
148
+     * Whether popover is visible or not.
135 149
      */
136 150
     popoverVisible: boolean;
137 151
 }
@@ -188,17 +202,16 @@ const styles = (theme: Theme) => {
188 202
  *
189 203
  * @augments {Component}
190 204
  */
191
-class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
205
+class ConnectionIndicator extends AbstractConnectionIndicator<IProps, IState> {
192 206
     /**
193 207
      * Initializes a new {@code ConnectionIndicator} instance.
194 208
      *
195 209
      * @param {Object} props - The read-only properties with which the new
196 210
      * instance is to be initialized.
197 211
      */
198
-    constructor(props: Props) {
212
+    constructor(props: IProps) {
199 213
         super(props);
200 214
 
201
-        // @ts-ignore
202 215
         this.state = {
203 216
             showIndicator: false,
204 217
             stats: {},
@@ -215,11 +228,9 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
215 228
      * @returns {ReactElement}
216 229
      */
217 230
     render() {
218
-        // @ts-ignore
219 231
         const { enableStatsDisplay, participantId, statsPopoverPosition, classes, t } = this.props;
220 232
         const visibilityClass = this._getVisibilityClass();
221 233
 
222
-        // @ts-ignore
223 234
         if (this.props._popoverDisabled) {
224 235
             return this._renderIndicator();
225 236
         }
@@ -228,8 +239,6 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
228 239
             <Popover
229 240
                 className = { clsx(classes.container, visibilityClass) }
230 241
                 content = { <ConnectionIndicatorContent
231
-
232
-                    // @ts-ignore
233 242
                     inheritedStats = { this.state.stats }
234 243
                     participantId = { participantId } /> }
235 244
                 disablePopover = { !enableStatsDisplay }
@@ -255,15 +264,12 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
255 264
      */
256 265
     _getConnectionColorClass() {
257 266
         // TODO We currently do not have logic to emit and handle stats changes for tracks.
258
-        // @ts-ignore
259 267
         const { percent } = this.state.stats;
260 268
 
261 269
         const {
262 270
             _isConnectionStatusInactive,
263 271
             _isConnectionStatusInterrupted,
264 272
             _connectionIndicatorInactiveDisabled
265
-
266
-            // @ts-ignore
267 273
         } = this.props;
268 274
 
269 275
         if (_isConnectionStatusInactive) {
@@ -304,13 +310,9 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
304 310
      * @returns {string}
305 311
      */
306 312
     _getVisibilityClass() {
307
-        // @ts-ignore
308 313
         const { _isConnectionStatusInactive, _isConnectionStatusInterrupted, classes } = this.props;
309 314
 
310
-        // @ts-ignore
311 315
         return this.state.showIndicator
312
-
313
-            // @ts-ignore
314 316
             || this.props.alwaysVisible
315 317
             || _isConnectionStatusInterrupted
316 318
             || _isConnectionStatusInactive
@@ -324,7 +326,6 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
324 326
      * @returns {void}
325 327
      */
326 328
     _onHidePopover() {
327
-        // @ts-ignore
328 329
         this.setState({ popoverVisible: false });
329 330
     }
330 331
 
@@ -335,7 +336,6 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
335 336
      * @returns {void}
336 337
      */
337 338
     _onShowPopover() {
338
-        // @ts-ignore
339 339
         this.setState({ popoverVisible: true });
340 340
     }
341 341
 
@@ -353,8 +353,6 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
353 353
             _videoTrack,
354 354
             classes,
355 355
             iconSize
356
-
357
-            // @ts-ignore
358 356
         } = this.props;
359 357
 
360 358
         return (
@@ -376,10 +374,10 @@ class ConnectionIndicator extends AbstractConnectionIndicator<Props, IState> {
376 374
  * Maps part of the Redux state to the props of this component.
377 375
  *
378 376
  * @param {Object} state - The Redux state.
379
- * @param {Props} ownProps - The own props of the component.
380
- * @returns {Props}
377
+ * @param {IProps} ownProps - The own props of the component.
378
+ * @returns {IProps}
381 379
  */
382
-export function _mapStateToProps(state: IReduxState, ownProps: Props) {
380
+export function _mapStateToProps(state: IReduxState, ownProps: IProps) {
383 381
     const { participantId } = ownProps;
384 382
     const tracks = state['features/base/tracks'];
385 383
     const participant = participantId ? getParticipantById(state, participantId) : getLocalParticipant(state);
@@ -397,14 +395,11 @@ export function _mapStateToProps(state: IReduxState, ownProps: Props) {
397 395
         _connectionIndicatorInactiveDisabled:
398 396
             Boolean(state['features/base/config'].connectionIndicators?.inactiveDisabled),
399 397
         _isVirtualScreenshareParticipant: isScreenShareParticipant(participant),
400
-        _popoverDisabled: state['features/base/config'].connectionIndicators?.disableDetails,
398
+        _popoverDisabled: Boolean(state['features/base/config'].connectionIndicators?.disableDetails),
401 399
         _isConnectionStatusInactive,
402 400
         _isConnectionStatusInterrupted,
403 401
         _videoTrack
404 402
     };
405 403
 }
406 404
 
407
-export default translate(connect(_mapStateToProps)(
408
-
409
-    // @ts-ignore
410
-    withStyles(styles)(ConnectionIndicator)));
405
+export default connect(_mapStateToProps)(translate(withStyles(styles)(ConnectionIndicator)));

+ 3
- 1
react/features/dropbox/functions.native.ts 查看文件

@@ -28,9 +28,11 @@ export async function _authorizeDropbox(_appKey?: any, _redirectURI?: any): Prom
28 28
 /**
29 29
  * Gets a new access token based on the refresh token.
30 30
  *
31
+ * @param {string} _appKey - The dropbox appKey.
32
+ * @param {string} _rToken - The refresh token.
31 33
  * @returns {Promise}
32 34
  */
33
-export function getNewAccessToken() {
35
+export function getNewAccessToken(_appKey: string, _rToken: string) {
34 36
     return _authorizeDropbox();
35 37
 }
36 38
 

react/features/filmstrip/components/AbstractRaisedHandIndicator.js → react/features/filmstrip/components/AbstractRaisedHandIndicator.ts 查看文件

@@ -1,27 +1,26 @@
1
-// @flow
1
+import React, { Component } from 'react';
2 2
 
3
-import { Component } from 'react';
3
+import { IReduxState } from '../../app/types';
4
+import { getParticipantById, hasRaisedHand } from '../../base/participants/functions';
4 5
 
5
-import { getParticipantById, hasRaisedHand } from '../../base/participants';
6
-
7
-export type Props = {
6
+export interface IProps {
8 7
 
9 8
     /**
10
-     * The participant id who we want to render the raised hand indicator
11
-     * for.
9
+     * True if the hand is raised for this participant.
12 10
      */
13
-    participantId: string,
11
+    _raisedHand?: boolean;
14 12
 
15 13
     /**
16
-     * True if the hand is raised for this participant.
14
+     * The participant id who we want to render the raised hand indicator
15
+     * for.
17 16
      */
18
-    _raisedHand?: boolean
17
+    participantId: string;
19 18
 }
20 19
 
21 20
 /**
22 21
  * Implements an abstract class for the RaisedHandIndicator component.
23 22
  */
24
-export default class AbstractRaisedHandIndicator<P: Props>
23
+export default class AbstractRaisedHandIndicator<P extends IProps>
25 24
     extends Component<P> {
26 25
 
27 26
     /**
@@ -42,7 +41,7 @@ export default class AbstractRaisedHandIndicator<P: Props>
42 41
      *
43 42
      * @returns {React$Element<*>}
44 43
      */
45
-    _renderIndicator: () => React$Element<*>;
44
+    _renderIndicator: () => React.ReactElement;
46 45
 
47 46
 }
48 47
 
@@ -50,10 +49,10 @@ export default class AbstractRaisedHandIndicator<P: Props>
50 49
  * Maps part of the Redux state to the props of this component.
51 50
  *
52 51
  * @param {Object} state - The Redux state.
53
- * @param {Props} ownProps - The own props of the component.
52
+ * @param {IProps} ownProps - The own props of the component.
54 53
  * @returns {Object}
55 54
  */
56
-export function _mapStateToProps(state: Object, ownProps: Props): Object {
55
+export function _mapStateToProps(state: IReduxState, ownProps: IProps) {
57 56
     const participant = getParticipantById(state, ownProps.participantId);
58 57
 
59 58
     return {

+ 2
- 2
react/features/filmstrip/components/web/ThumbnailTopIndicators.tsx 查看文件

@@ -104,7 +104,7 @@ const ThumbnailTopIndicators = ({
104 104
     if (isVirtualScreenshareParticipant) {
105 105
         return (
106 106
             <div className = { styles.container }>
107
-                {!_connectionIndicatorDisabled
107
+                {!_connectionIndicatorDisabled // @ts-ignore
108 108
                     && <ConnectionIndicator
109 109
                         alwaysVisible = { showConnectionIndicator }
110 110
                         enableStatsDisplay = { true }
@@ -124,7 +124,7 @@ const ThumbnailTopIndicators = ({
124 124
                 iconSize = { _indicatorIconSize }
125 125
                 participantId = { participantId }
126 126
                 tooltipPosition = { tooltipPosition } />
127
-            {!_connectionIndicatorDisabled
127
+            {!_connectionIndicatorDisabled // @ts-ignore
128 128
                 && <ConnectionIndicator
129 129
                     alwaysVisible = { showConnectionIndicator }
130 130
                     enableStatsDisplay = { true }

react/features/overlay/components/web/AbstractPageReloadOverlay.js → react/features/overlay/components/web/AbstractPageReloadOverlay.tsx 查看文件

@@ -1,96 +1,91 @@
1
-// @flow
2
-
1
+// @ts-ignore
3 2
 import { randomInt } from '@jitsi/js-utils/random';
4 3
 import React, { Component } from 'react';
5
-import type { Dispatch } from 'redux';
4
+import { WithTranslation } from 'react-i18next';
6 5
 
7
-import {
8
-    createPageReloadScheduledEvent,
9
-    sendAnalytics
10
-} from '../../../analytics';
11
-import { reloadNow } from '../../../app/actions';
6
+import { createPageReloadScheduledEvent } from '../../../analytics/AnalyticsEvents';
7
+import { sendAnalytics } from '../../../analytics/functions';
8
+import { reloadNow } from '../../../app/actions.web';
9
+import { IReduxState, IStore } from '../../../app/types';
12 10
 import {
13 11
     isFatalJitsiConferenceError,
14 12
     isFatalJitsiConnectionError
15
-} from '../../../base/lib-jitsi-meet/functions';
13
+} from '../../../base/lib-jitsi-meet/functions.web';
16 14
 import logger from '../../logger';
17 15
 
16
+// @ts-ignore
18 17
 import ReloadButton from './ReloadButton';
19 18
 
20
-declare var APP: Object;
21
-
22 19
 /**
23 20
  * The type of the React {@code Component} props of
24 21
  * {@link AbstractPageReloadOverlay}.
25 22
  */
26
-export type Props = {
23
+export interface IProps extends WithTranslation {
27 24
 
28 25
     /**
29 26
      * The details is an object containing more information about the connection
30 27
      * failed (shard changes, was the computer suspended, etc.).
31 28
      */
32
-    details: Object,
29
+    details: Object;
33 30
 
34
-    dispatch: Dispatch<any>,
31
+    /**
32
+     * Redux dispatch function.
33
+     */
34
+    dispatch: IStore['dispatch'];
35 35
 
36 36
     /**
37 37
      * The error that caused the display of the overlay.
38 38
      */
39
-    error: Error,
39
+    error: Error;
40 40
 
41 41
     /**
42 42
      * The indicator which determines whether the reload was caused by network
43 43
      * failure.
44 44
      */
45
-    isNetworkFailure: boolean,
45
+    isNetworkFailure: boolean;
46 46
 
47 47
     /**
48 48
      * The reason for the error that will cause the reload.
49 49
      * NOTE: Used by PageReloadOverlay only.
50 50
      */
51
-    reason: string,
52
-
53
-    /**
54
-     * The function to translate human-readable text.
55
-     */
56
-    t: Function
57
-};
51
+    reason: string;
52
+}
58 53
 
59 54
 /**
60 55
  * The type of the React {@code Component} state of
61 56
  * {@link AbstractPageReloadOverlay}.
62 57
  */
63
-type State = {
58
+interface IState {
64 59
 
65 60
     /**
66 61
      * The translation key for the title of the overlay.
67 62
      */
68
-    message: string,
63
+    message: string;
69 64
 
70 65
     /**
71 66
      * Current value(time) of the timer.
72 67
      */
73
-    timeLeft: number,
68
+    timeLeft: number;
74 69
 
75 70
     /**
76 71
      * How long the overlay dialog will be displayed before the conference will
77 72
      * be reloaded.
78 73
      */
79
-    timeoutSeconds: number,
74
+    timeoutSeconds: number;
80 75
 
81 76
     /**
82 77
      * The translation key for the title of the overlay.
83 78
      */
84
-    title: string
85
-};
79
+    title: string;
80
+}
86 81
 
87 82
 /**
88 83
  * Implements an abstract React {@link Component} for the page reload overlays.
89 84
  *
90 85
  * FIXME: This is not really an abstract class as some components and functions are very web specific.
91 86
  */
92
-export default class AbstractPageReloadOverlay<P: Props>
93
-    extends Component<P, State> {
87
+export default class AbstractPageReloadOverlay<P extends IProps>
88
+    extends Component<P, IState> {
94 89
 
95 90
     /**
96 91
      * Determines whether this overlay needs to be rendered (according to a
@@ -100,7 +95,7 @@ export default class AbstractPageReloadOverlay<P: Props>
100 95
      * @returns {boolean} - If this overlay needs to be rendered, {@code true};
101 96
      * {@code false}, otherwise.
102 97
      */
103
-    static needsRender(state: Object) {
98
+    static needsRender(state: IReduxState) {
104 99
         const { error: conferenceError } = state['features/base/conference'];
105 100
         const { error: configError } = state['features/base/config'];
106 101
         const { error: connectionError } = state['features/base/connection'];
@@ -115,7 +110,7 @@ export default class AbstractPageReloadOverlay<P: Props>
115 110
         return jitsiConnectionError || jitsiConferenceError || configError;
116 111
     }
117 112
 
118
-    _interval: ?IntervalID;
113
+    _interval: number | undefined;
119 114
 
120 115
     /**
121 116
      * Initializes a new AbstractPageReloadOverlay instance.
@@ -164,13 +159,11 @@ export default class AbstractPageReloadOverlay<P: Props>
164 159
         // because the log queue is not flushed before "fabric terminated" is
165 160
         // sent to the backed.
166 161
         // FIXME: We should dispatch action for this.
167
-        if (typeof APP !== 'undefined') {
168
-            if (APP.conference && APP.conference._room) {
169
-                APP.conference._room.sendApplicationLog(JSON.stringify({
170
-                    name: 'page.reload',
171
-                    label: this.props.reason
172
-                }));
173
-            }
162
+        if (typeof APP !== 'undefined' && APP.conference?._room) {
163
+            APP.conference._room.sendApplicationLog(JSON.stringify({
164
+                name: 'page.reload',
165
+                label: this.props.reason
166
+            }));
174 167
         }
175 168
 
176 169
         sendAnalytics(createPageReloadScheduledEvent(
@@ -183,7 +176,7 @@ export default class AbstractPageReloadOverlay<P: Props>
183 176
                 this.state.timeoutSeconds} seconds.`);
184 177
 
185 178
         this._interval
186
-            = setInterval(
179
+            = window.setInterval(
187 180
                 () => {
188 181
                     if (this.state.timeLeft === 0) {
189 182
                         if (this._interval) {
@@ -268,7 +261,7 @@ export default class AbstractPageReloadOverlay<P: Props>
268 261
  *     reason: string
269 262
  * }}
270 263
  */
271
-export function abstractMapStateToProps(state: Object) {
264
+export function abstractMapStateToProps(state: IReduxState) {
272 265
     const { error: configError } = state['features/base/config'];
273 266
     const { error: connectionError } = state['features/base/connection'];
274 267
     const { fatalError } = state['features/overlay'];
@@ -290,7 +283,7 @@ export function abstractMapStateToProps(state: Object) {
290 283
     }
291 284
 
292 285
     return {
293
-        details: fatalError && fatalError.details,
286
+        details: fatalError?.details,
294 287
         error: fatalError,
295 288
         isNetworkFailure:
296 289
             fatalError === configError || fatalError === connectionError,

react/features/overlay/components/web/AbstractSuspendedOverlay.js → react/features/overlay/components/web/AbstractSuspendedOverlay.ts 查看文件

@@ -1,18 +1,13 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
2
+import { WithTranslation } from 'react-i18next';
3
+
4
+import { IReduxState } from '../../../app/types';
4 5
 
5 6
 /**
6 7
  * The type of the React {@code Component} props of
7 8
  * {@link AbstractSuspendedOverlay}.
8 9
  */
9
-type Props = {
10
-
11
-    /**
12
-     * The function to translate human-readable text.
13
-     */
14
-    t: Function
15
-};
10
+type Props = WithTranslation;
16 11
 
17 12
 /**
18 13
  * Implements a React {@link Component} for suspended overlay. Shown when a
@@ -27,7 +22,7 @@ export default class AbstractSuspendedOverlay extends Component<Props> {
27 22
      * @returns {boolean} - If this overlay needs to be rendered, {@code true};
28 23
      * {@code false}, otherwise.
29 24
      */
30
-    static needsRender(state: Object) {
25
+    static needsRender(state: IReduxState) {
31 26
         return state['features/power-monitor']?.suspendDetected;
32 27
     }
33 28
 }

react/features/overlay/components/web/AbstractUserMediaPermissionsOverlay.js → react/features/overlay/components/web/AbstractUserMediaPermissionsOverlay.ts 查看文件

@@ -1,31 +1,27 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
2
+import { WithTranslation } from 'react-i18next';
3
+
4
+import { IReduxState } from '../../../app/types';
4 5
 
5 6
 /**
6 7
  * The type of the React {@code Component} props of
7 8
  * {@link AbstractUserMediaPermissionsOverlay}.
8 9
  */
9
-type Props = {
10
+interface IProps extends WithTranslation {
10 11
 
11 12
     /**
12 13
      * The browser which is used currently. The text is different for every
13 14
      * browser.
14 15
      */
15
-    browser: string,
16
-
17
-    /**
18
-     * The function to translate human-readable text.
19
-     */
20
-    t: Function
21
-};
16
+    browser: string;
17
+}
22 18
 
23 19
 /**
24 20
  * Implements a React {@link Component} for overlay with guidance how to proceed
25 21
  * with gUM prompt.
26 22
  */
27 23
 export default class AbstractUserMediaPermissionsOverlay
28
-    extends Component<Props> {
24
+    extends Component<IProps> {
29 25
     /**
30 26
      * Determines whether this overlay needs to be rendered (according to a
31 27
      * specific redux state). Called by {@link OverlayContainer}.
@@ -34,7 +30,7 @@ export default class AbstractUserMediaPermissionsOverlay
34 30
      * @returns {boolean} - If this overlay needs to be rendered, {@code true};
35 31
      * {@code false}, otherwise.
36 32
      */
37
-    static needsRender(state: Object) {
33
+    static needsRender(state: IReduxState) {
38 34
         return state['features/overlay'].isMediaPermissionPromptVisible;
39 35
     }
40 36
 }
@@ -48,7 +44,7 @@ export default class AbstractUserMediaPermissionsOverlay
48 44
  *     browser: string
49 45
  * }}
50 46
  */
51
-export function abstractMapStateToProps(state: Object) {
47
+export function abstractMapStateToProps(state: IReduxState) {
52 48
     const { browser } = state['features/overlay'];
53 49
 
54 50
     return {

+ 5
- 1
react/features/overlay/reducer.ts 查看文件

@@ -6,7 +6,11 @@ import { MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED } from './actionTypes';
6 6
 
7 7
 export interface IOverlayState {
8 8
     browser?: string;
9
-    fatalError?: Error;
9
+    fatalError?: {
10
+        details: Object;
11
+        message?: string;
12
+        name?: string;
13
+    };
10 14
     isMediaPermissionPromptVisible?: boolean;
11 15
 }
12 16
 

+ 1
- 1
react/features/recording/actions.any.ts 查看文件

@@ -350,7 +350,7 @@ function _setPendingRecordingNotificationUid(uid: string | undefined, streamType
350 350
  * @param {boolean} onlySelf - Whether to only record the local streams.
351 351
  * @returns {Object}
352 352
  */
353
-export function startLocalVideoRecording(onlySelf: boolean) {
353
+export function startLocalVideoRecording(onlySelf?: boolean) {
354 354
     return {
355 355
         type: START_LOCAL_RECORDING,
356 356
         onlySelf

react/features/recording/components/Recording/AbstractStartRecordingDialog.js → react/features/recording/components/Recording/AbstractStartRecordingDialog.ts 查看文件

@@ -1,142 +1,138 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
2
+import { WithTranslation } from 'react-i18next';
4 3
 
5
-import {
6
-    createRecordingDialogEvent,
7
-    sendAnalytics
8
-} from '../../../analytics';
4
+import { createRecordingDialogEvent } from '../../../analytics/AnalyticsEvents';
5
+import { sendAnalytics } from '../../../analytics/functions';
6
+import { IReduxState, IStore } from '../../../app/types';
7
+import { IJitsiConference } from '../../../base/conference/reducer';
9 8
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
10
-import {
11
-    getDropboxData,
12
-    getNewAccessToken,
13
-    isEnabled as isDropboxEnabled,
14
-    updateDropboxToken
15
-} from '../../../dropbox';
16
-import { NOTIFICATION_TIMEOUT_TYPE, showErrorNotification } from '../../../notifications';
17
-import { toggleRequestingSubtitles } from '../../../subtitles';
9
+import { updateDropboxToken } from '../../../dropbox/actions';
10
+import { getDropboxData, getNewAccessToken, isEnabled as isDropboxEnabled } from '../../../dropbox/functions.any';
11
+import { showErrorNotification } from '../../../notifications/actions';
12
+import { NOTIFICATION_TIMEOUT_TYPE } from '../../../notifications/constants';
13
+import { toggleRequestingSubtitles } from '../../../subtitles/actions';
18 14
 import { setSelectedRecordingService, startLocalVideoRecording } from '../../actions';
19 15
 import { RECORDING_TYPES } from '../../constants';
20 16
 import { supportsLocalRecording } from '../../functions';
21 17
 
22
-export type Props = {
18
+export interface IProps extends WithTranslation {
23 19
 
24 20
     /**
25
-     * Requests subtitles when recording is turned on.
21
+     * The app key for the dropbox authentication.
26 22
      */
27
-    _autoCaptionOnRecord: boolean,
23
+    _appKey: string;
28 24
 
29 25
     /**
30
-     * The {@code JitsiConference} for the current conference.
26
+     * Requests subtitles when recording is turned on.
31 27
      */
32
-    _conference: Object,
28
+    _autoCaptionOnRecord: boolean;
33 29
 
34 30
     /**
35
-     * The app key for the dropbox authentication.
31
+     * The {@code JitsiConference} for the current conference.
36 32
      */
37
-    _appKey: string,
33
+    _conference: IJitsiConference;
38 34
 
39 35
     /**
40 36
      * Whether to show file recordings service, even if integrations
41 37
      * are enabled.
42 38
      */
43
-    _fileRecordingsServiceEnabled: boolean,
39
+    _fileRecordingsServiceEnabled: boolean;
44 40
 
45 41
     /**
46 42
      * Whether to show the possibility to share file recording with other people (e.g. Meeting participants), based on
47 43
      * the actual implementation on the backend.
48 44
      */
49
-    _fileRecordingsServiceSharingEnabled: boolean,
45
+    _fileRecordingsServiceSharingEnabled: boolean;
50 46
 
51 47
     /**
52 48
      * If true the dropbox integration is enabled, otherwise - disabled.
53 49
      */
54
-    _isDropboxEnabled: boolean,
50
+    _isDropboxEnabled: boolean;
55 51
 
56 52
     /**
57 53
      * Whether or not local recording is enabled.
58 54
      */
59
-    _localRecordingEnabled: boolean,
55
+    _localRecordingEnabled: boolean;
60 56
 
61 57
     /**
62 58
      * The dropbox refresh token.
63 59
      */
64
-    _rToken: string,
60
+    _rToken: string;
65 61
 
66 62
     /**
67 63
      * Whether or not the local participant is screensharing.
68 64
      */
69
-    _screensharing: boolean,
65
+    _screensharing: boolean;
70 66
 
71 67
     /**
72 68
      * Whether or not the screenshot capture feature is enabled.
73 69
      */
74
-    _screenshotCaptureEnabled: boolean,
75
-
76
-    /**
77
-     * Access token's expiration date as UNIX timestamp.
78
-     */
79
-    _tokenExpireDate?: number,
70
+    _screenshotCaptureEnabled: boolean;
80 71
 
81 72
     /**
82 73
      * The dropbox access token.
83 74
      */
84
-    _token: string,
75
+    _token: string;
85 76
 
86 77
     /**
87
-     * The redux dispatch function.
78
+     * Access token's expiration date as UNIX timestamp.
88 79
      */
89
-    dispatch: Function,
80
+    _tokenExpireDate?: number;
90 81
 
91 82
     /**
92
-     * Invoked to obtain translated strings.
83
+     * The redux dispatch function.
93 84
      */
94
-    t: Function
85
+    dispatch: IStore['dispatch'];
95 86
 }
96 87
 
97
-type State = {
88
+interface IState {
98 89
 
99 90
     /**
100 91
      * <tt>true</tt> if we have valid oauth token.
101 92
      */
102
-    isTokenValid: boolean,
93
+    isTokenValid: boolean;
103 94
 
104 95
     /**
105 96
      * <tt>true</tt> if we are in process of validating the oauth token.
106 97
      */
107
-    isValidating: boolean,
98
+    isValidating: boolean;
99
+
100
+    /**
101
+     * Whether the local recording should record just the local user streams.
102
+     */
103
+    localRecordingOnlySelf?: boolean;
108 104
 
109 105
     /**
110 106
      * The currently selected recording service of type: RECORDING_TYPES.
111 107
      */
112
-    selectedRecordingService: ?string,
108
+    selectedRecordingService?: string;
113 109
 
114 110
     /**
115 111
      * True if the user requested the service to share the recording with others.
116 112
      */
117
-    sharingEnabled: boolean,
113
+    sharingEnabled: boolean;
118 114
 
119 115
     /**
120 116
      * Number of MiB of available space in user's Dropbox account.
121 117
      */
122
-    spaceLeft: ?number,
118
+    spaceLeft?: number;
123 119
 
124 120
     /**
125 121
      * The display name of the user's Dropbox account.
126 122
      */
127
-    userName: ?string
128
-};
123
+    userName?: string;
124
+}
129 125
 
130 126
 /**
131 127
  * Component for the recording start dialog.
132 128
  */
133
-class AbstractStartRecordingDialog extends Component<Props, State> {
129
+class AbstractStartRecordingDialog extends Component<IProps, IState> {
134 130
     /**
135 131
      * Initializes a new {@code StartRecordingDialog} instance.
136 132
      *
137 133
      * @inheritdoc
138 134
      */
139
-    constructor(props: Props) {
135
+    constructor(props: IProps) {
140 136
         super(props);
141 137
 
142 138
         // Bind event handler so it is only bound once for every instance.
@@ -191,14 +187,12 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
191 187
      * @inheritdoc
192 188
      * @returns {void}
193 189
      */
194
-    componentDidUpdate(prevProps: Props) {
190
+    componentDidUpdate(prevProps: IProps) {
195 191
         if (this.props._token !== prevProps._token) {
196 192
             this._onTokenUpdated();
197 193
         }
198 194
     }
199 195
 
200
-    _areIntegrationsEnabled: () => boolean;
201
-
202 196
     /**
203 197
      * Returns true if the integrations with third party services are enabled
204 198
      * and false otherwise.
@@ -210,8 +204,6 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
210 204
         return this.props._isDropboxEnabled;
211 205
     }
212 206
 
213
-    _onSharingSettingChanged: () => void;
214
-
215 207
     /**
216 208
      * Callback to handle sharing setting change from the dialog.
217 209
      *
@@ -223,8 +215,6 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
223 215
         });
224 216
     }
225 217
 
226
-    _onLocalRecordingSelfChange: () => void;
227
-
228 218
     /**
229 219
      * Callback to handle local recording only self setting change.
230 220
      *
@@ -236,8 +226,6 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
236 226
         });
237 227
     }
238 228
 
239
-    _onSelectedRecordingServiceChanged: (string) => void;
240
-
241 229
     /**
242 230
      * Handles selected recording service changes.
243 231
      *
@@ -245,7 +233,7 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
245 233
      * service.
246 234
      * @returns {void}
247 235
      */
248
-    _onSelectedRecordingServiceChanged(selectedRecordingService) {
236
+    _onSelectedRecordingServiceChanged(selectedRecordingService: string) {
249 237
         this.setState({ selectedRecordingService }, () => {
250 238
             this.props.dispatch(setSelectedRecordingService(selectedRecordingService));
251 239
         });
@@ -268,10 +256,11 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
268 256
                 isTokenValid: false,
269 257
                 isValidating: false
270 258
             });
271
-        } else {
259
+        } else { // @ts-ignore
272 260
             if (_tokenExpireDate && Date.now() > new Date(_tokenExpireDate)) {
273 261
                 getNewAccessToken(_appKey, _rToken)
274
-                    .then(resp => dispatch(updateDropboxToken(resp.token, resp.rToken, resp.expireDate)));
262
+                    .then((resp: { expireDate: number; rToken: string; token: string; }) =>
263
+                        dispatch(updateDropboxToken(resp.token, resp.rToken, resp.expireDate)));
275 264
 
276 265
                 return;
277 266
             }
@@ -297,8 +286,6 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
297 286
         }
298 287
     }
299 288
 
300
-    _onSubmit: () => boolean;
301
-
302 289
     /**
303 290
      * Starts a file recording session.
304 291
      *
@@ -316,7 +303,9 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
316 303
             dispatch
317 304
         } = this.props;
318 305
         let appData;
319
-        const attributes = {};
306
+        const attributes: {
307
+            type?: string;
308
+        } = {};
320 309
 
321 310
         switch (this.state.selectedRecordingService) {
322 311
         case RECORDING_TYPES.DROPBOX: {
@@ -374,8 +363,6 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
374 363
         return true;
375 364
     }
376 365
 
377
-    _toggleScreenshotCapture:() => void;
378
-
379 366
     /**
380 367
      * Toggles screenshot capture feature.
381 368
      *
@@ -391,7 +378,7 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
391 378
      * @protected
392 379
      * @returns {React$Component}
393 380
      */
394
-    _renderDialogContent: () => React$Component<*>;
381
+    _renderDialogContent: () => React.Component;
395 382
 }
396 383
 
397 384
 /**
@@ -412,11 +399,11 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
412 399
  *     _token: string
413 400
  * }}
414 401
  */
415
-export function mapStateToProps(state: Object) {
402
+export function mapStateToProps(state: IReduxState) {
416 403
     const {
417 404
         transcription,
418 405
         recordingService,
419
-        dropbox = {},
406
+        dropbox = { appKey: undefined },
420 407
         localRecording
421 408
     } = state['features/base/config'];
422 409
 

Loading…
取消
儲存