Переглянути джерело

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

factor2
Robert Pintilii 2 роки тому
джерело
коміт
bc1827fb4a
Аккаунт користувача з таким Email не знайдено

+ 1
- 1
react/features/analytics/AnalyticsEvents.ts Переглянути файл

@@ -887,7 +887,7 @@ export function createVpaasConferenceJoinedEvent(tenant: string) {
887 887
  * @returns {Object} The event in a format suitable for sending via
888 888
  * sendAnalytics.
889 889
  */
890
-export function createWelcomePageEvent(action: string, actionSubject: string, attributes = {}) {
890
+export function createWelcomePageEvent(action: string, actionSubject?: string, attributes = {}) {
891 891
     return {
892 892
         action,
893 893
         actionSubject,

+ 2
- 0
react/features/base/conference/reducer.ts Переглянути файл

@@ -93,7 +93,9 @@ export interface IJitsiConference {
93 93
     setReceiverConstraints: Function;
94 94
     setSenderVideoConstraint: Function;
95 95
     setSubject: Function;
96
+    startRecording: Function;
96 97
     startVerification: Function;
98
+    stopRecording: Function;
97 99
 }
98 100
 
99 101
 export interface IConferenceState {

react/features/chat/components/AbstractChat.js → react/features/chat/components/AbstractChat.ts Переглянути файл

@@ -1,98 +1,92 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
4
-import type { Dispatch } from 'redux';
2
+import { WithTranslation } from 'react-i18next';
5 3
 
6
-import { getLocalParticipant } from '../../base/participants';
4
+import { IReduxState, IStore } from '../../app/types';
5
+import { getLocalParticipant } from '../../base/participants/functions';
7 6
 import { sendMessage, setIsPollsTabFocused } from '../actions';
8 7
 import { SMALL_WIDTH_THRESHOLD } from '../constants';
9 8
 
10 9
 /**
11 10
  * The type of the React {@code Component} props of {@code AbstractChat}.
12 11
  */
13
-export type Props = {
12
+export interface IProps extends WithTranslation {
14 13
 
15 14
     /**
16 15
      * Whether the chat is opened in a modal or not (computed based on window width).
17 16
      */
18
-    _isModal: boolean,
17
+    _isModal: boolean;
19 18
 
20 19
     /**
21 20
      * True if the chat window should be rendered.
22 21
      */
23
-    _isOpen: boolean,
22
+    _isOpen: boolean;
24 23
 
25 24
     /**
26 25
      * True if the polls feature is enabled.
27 26
      */
28
-    _isPollsEnabled: boolean,
27
+    _isPollsEnabled: boolean;
29 28
 
30 29
     /**
31 30
      * Whether the poll tab is focused or not.
32 31
      */
33
-    _isPollsTabFocused: boolean,
32
+    _isPollsTabFocused: boolean;
34 33
 
35 34
     /**
36 35
      * All the chat messages in the conference.
37 36
      */
38
-    _messages: Array<Object>,
37
+    _messages: Array<Object>;
39 38
 
40 39
     /**
41 40
      * Number of unread chat messages.
42 41
      */
43
-    _nbUnreadMessages: number,
42
+    _nbUnreadMessages: number;
44 43
 
45 44
     /**
46 45
      * Number of unread poll messages.
47 46
      */
48
-    _nbUnreadPolls: number,
47
+    _nbUnreadPolls: number;
49 48
 
50 49
     /**
51 50
      * Function to send a text message.
52 51
      *
53 52
      * @protected
54 53
      */
55
-    _onSendMessage: Function,
54
+    _onSendMessage: Function;
55
+
56
+    /**
57
+     * Function to toggle the chat window.
58
+     */
59
+    _onToggleChat: Function;
56 60
 
57 61
     /**
58 62
      * Function to display the chat tab.
59 63
      *
60 64
      * @protected
61 65
      */
62
-    _onToggleChatTab: Function,
66
+    _onToggleChatTab: Function;
63 67
 
64 68
     /**
65 69
      * Function to display the polls tab.
66 70
      *
67 71
      * @protected
68 72
      */
69
-    _onTogglePollsTab: Function,
70
-
71
-    /**
72
-     * Function to toggle the chat window.
73
-     */
74
-    _onToggleChat: Function,
73
+    _onTogglePollsTab: Function;
75 74
 
76 75
     /**
77 76
      * Whether or not to block chat access with a nickname input form.
78 77
      */
79
-    _showNamePrompt: boolean,
78
+    _showNamePrompt: boolean;
80 79
 
81 80
     /**
82 81
      * The Redux dispatch function.
83 82
      */
84
-    dispatch: Dispatch<any>,
85
-
86
-    /**
87
-     * Function to be used to translate i18n labels.
88
-     */
89
-    t: Function,
90
-};
83
+    dispatch: IStore['dispatch'];
84
+}
91 85
 
92 86
 /**
93 87
  * Implements an abstract chat panel.
94 88
  */
95
-export default class AbstractChat<P: Props> extends Component<P> {
89
+export default class AbstractChat<P extends IProps> extends Component<P> {
96 90
 
97 91
     /**
98 92
      * Initializes a new {@code AbstractChat} instance.
@@ -109,8 +103,6 @@ export default class AbstractChat<P: Props> extends Component<P> {
109 103
         this._onTogglePollsTab = this._onTogglePollsTab.bind(this);
110 104
     }
111 105
 
112
-    _onSendMessage: (string) => void;
113
-
114 106
     /**
115 107
     * Sends a text message.
116 108
     *
@@ -123,8 +115,6 @@ export default class AbstractChat<P: Props> extends Component<P> {
123 115
         this.props.dispatch(sendMessage(text));
124 116
     }
125 117
 
126
-    _onToggleChatTab: () => void;
127
-
128 118
     /**
129 119
      * Display the Chat tab.
130 120
      *
@@ -135,8 +125,6 @@ export default class AbstractChat<P: Props> extends Component<P> {
135 125
         this.props.dispatch(setIsPollsTabFocused(false));
136 126
     }
137 127
 
138
-    _onTogglePollsTab: () => void;
139
-
140 128
     /**
141 129
      * Display the Polls tab.
142 130
      *
@@ -160,7 +148,7 @@ export default class AbstractChat<P: Props> extends Component<P> {
160 148
  *     _showNamePrompt: boolean
161 149
  * }}
162 150
  */
163
-export function _mapStateToProps(state: Object) {
151
+export function _mapStateToProps(state: IReduxState) {
164 152
     const { isOpen, isPollsTabFocused, messages, nbUnreadMessages } = state['features/chat'];
165 153
     const { nbUnreadPolls } = state['features/polls'];
166 154
     const _localParticipant = getLocalParticipant(state);

react/features/recording/components/AbstractRecordingLabel.js → react/features/recording/components/AbstractRecordingLabel.ts Переглянути файл

@@ -1,7 +1,7 @@
1
-// @flow
2
-
3
-import { Component } from 'react';
1
+import React, { Component } from 'react';
2
+import { WithTranslation } from 'react-i18next';
4 3
 
4
+import { IReduxState } from '../../app/types';
5 5
 import { JitsiRecordingConstants } from '../../base/lib-jitsi-meet';
6 6
 import { getSessionStatusToShow } from '../functions';
7 7
 
@@ -13,44 +13,39 @@ import { getSessionStatusToShow } from '../functions';
13 13
  * running. These boolean are shared across the two components to make it
14 14
  * easier to align web's behaviour to mobile's later if necessary.
15 15
  */
16
-type Props = {
16
+interface IProps extends WithTranslation {
17 17
 
18 18
     /**
19 19
      * Whether this is the Jibri recorder participant.
20 20
      */
21
-    _iAmRecorder: boolean,
21
+    _iAmRecorder: boolean;
22 22
 
23 23
     /**
24 24
      * The status of the highermost priority session.
25 25
      */
26
-    _status: ?string,
26
+    _status?: string;
27 27
 
28 28
     /**
29 29
      * An object containing the CSS classes.
30 30
      */
31
-    classes: ?{[ key: string]: string},
31
+    classes?: { [ key: string]: string; };
32 32
 
33 33
     /**
34 34
      * The recording mode this indicator should display.
35 35
      */
36
-    mode: string,
37
-
38
-    /**
39
-     * Invoked to obtain translated strings.
40
-     */
41
-    t: Function
42
-};
36
+    mode: string;
37
+}
43 38
 
44 39
 /**
45 40
  * State of the component.
46 41
  */
47
-type State = {
42
+interface IState {
48 43
 
49 44
     /**
50 45
      * True if the label status is stale, so it needs to be removed.
51 46
      */
52
-    staleLabel: boolean
53
-};
47
+    staleLabel: boolean;
48
+}
54 49
 
55 50
 /**
56 51
  * The timeout after a label is considered stale. See {@code _updateStaleStatus}
@@ -62,13 +57,15 @@ const STALE_TIMEOUT = 10 * 1000;
62 57
  * Abstract class for the {@code RecordingLabel} component.
63 58
  */
64 59
 export default class AbstractRecordingLabel
65
-    extends Component<Props, State> {
60
+    extends Component<IProps, IState> {
61
+    _mounted: boolean;
62
+
66 63
     /**
67 64
      * Implements {@code Component#getDerivedStateFromProps}.
68 65
      *
69 66
      * @inheritdoc
70 67
      */
71
-    static getDerivedStateFromProps(props: Props, prevState: State) {
68
+    static getDerivedStateFromProps(props: IProps, prevState: IState) {
72 69
         return {
73 70
             staleLabel: props._status !== JitsiRecordingConstants.status.OFF
74 71
                 && prevState.staleLabel ? false : prevState.staleLabel
@@ -80,14 +77,14 @@ export default class AbstractRecordingLabel
80 77
      *
81 78
      * @inheritdoc
82 79
      */
83
-    constructor(props: Props) {
80
+    constructor(props: IProps) {
84 81
         super(props);
85 82
 
86 83
         this.state = {
87 84
             staleLabel: true
88 85
         };
89 86
 
90
-        this._updateStaleStatus({}, props);
87
+        this._updateStaleStatus(undefined, props);
91 88
     }
92 89
 
93 90
     /**
@@ -113,7 +110,7 @@ export default class AbstractRecordingLabel
113 110
      *
114 111
      * @inheritdoc
115 112
      */
116
-    componentDidUpdate(prevProps: Props) {
113
+    componentDidUpdate(prevProps: IProps) {
117 114
         this._updateStaleStatus(prevProps, this.props);
118 115
     }
119 116
 
@@ -127,8 +124,6 @@ export default class AbstractRecordingLabel
127 124
             ? this._renderLabel() : null;
128 125
     }
129 126
 
130
-    _getLabelKey: () => ?string;
131
-
132 127
     /**
133 128
      * Returns the label key that this indicator should render.
134 129
      *
@@ -153,19 +148,21 @@ export default class AbstractRecordingLabel
153 148
      * @protected
154 149
      * @returns {React$Element}
155 150
      */
156
-    _renderLabel: () => React$Element<*>;
151
+    _renderLabel(): React.ReactNode | null {
152
+        return null;
153
+    }
157 154
 
158 155
     /**
159 156
      * Updates the stale status of the label on a prop change. A label is stale
160 157
      * if it's in a {@code _status} that doesn't need to be rendered anymore.
161 158
      *
162
-     * @param {Props} oldProps - The previous props of the component.
163
-     * @param {Props} newProps - The new props of the component.
159
+     * @param {IProps} oldProps - The previous props of the component.
160
+     * @param {IProps} newProps - The new props of the component.
164 161
      * @returns {void}
165 162
      */
166
-    _updateStaleStatus(oldProps, newProps) {
163
+    _updateStaleStatus(oldProps: IProps | undefined, newProps: IProps) {
167 164
         if (newProps._status === JitsiRecordingConstants.status.OFF) {
168
-            if (oldProps._status !== JitsiRecordingConstants.status.OFF) {
165
+            if (oldProps?._status !== JitsiRecordingConstants.status.OFF) {
169 166
                 setTimeout(() => {
170 167
                     if (!this._mounted) {
171 168
                         return;
@@ -189,13 +186,13 @@ export default class AbstractRecordingLabel
189 186
  * {@code AbstractRecordingLabel}'s props.
190 187
  *
191 188
  * @param {Object} state - The Redux state.
192
- * @param {Props} ownProps - The component's own props.
189
+ * @param {IProps} ownProps - The component's own props.
193 190
  * @private
194 191
  * @returns {{
195 192
  *     _status: ?string
196 193
  * }}
197 194
  */
198
-export function _mapStateToProps(state: Object, ownProps: Props) {
195
+export function _mapStateToProps(state: IReduxState, ownProps: IProps) {
199 196
     const { mode } = ownProps;
200 197
 
201 198
     return {

react/features/recording/components/LiveStream/AbstractStartLiveStreamDialog.js → react/features/recording/components/LiveStream/AbstractStartLiveStreamDialog.ts Переглянути файл

@@ -1,81 +1,79 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
4 2
 
5
-import {
6
-    createLiveStreamingDialogEvent,
7
-    sendAnalytics
8
-} from '../../../analytics';
3
+import { createLiveStreamingDialogEvent } from '../../../analytics/AnalyticsEvents';
4
+import { sendAnalytics } from '../../../analytics/functions';
5
+import { IReduxState } from '../../../app/types';
6
+import { IJitsiConference } from '../../../base/conference/reducer';
9 7
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
10 8
 
11 9
 /**
12 10
  * The type of the React {@code Component} props of
13 11
  * {@link AbstractStartLiveStreamDialog}.
14 12
  */
15
-export type Props = {
13
+export interface IProps {
16 14
 
17 15
     /**
18 16
      * The {@code JitsiConference} for the current conference.
19 17
      */
20
-    _conference: Object,
18
+    _conference: IJitsiConference;
21 19
 
22 20
     /**
23 21
      * The current state of interactions with the Google API. Determines what
24 22
      * Google related UI should display.
25 23
      */
26
-    _googleAPIState: number,
24
+    _googleAPIState: number;
27 25
 
28 26
     /**
29 27
      * The email of the user currently logged in to the Google web client
30 28
      * application.
31 29
      */
32
-    _googleProfileEmail: string,
30
+    _googleProfileEmail: string;
33 31
 
34 32
     /**
35 33
      * The live stream key that was used before.
36 34
      */
37
-    _streamKey: string,
35
+    _streamKey: string;
38 36
 
39 37
     /**
40 38
      * The Redux dispatch function.
41 39
      */
42
-    dispatch: Function,
40
+    dispatch: Function;
43 41
 
44 42
     /**
45 43
      * Invoked to obtain translated strings.
46 44
      */
47
-    t: Function
45
+    t: Function;
48 46
 }
49 47
 
50 48
 /**
51 49
  * The type of the React {@code Component} state of
52 50
  * {@link AbstractStartLiveStreamDialog}.
53 51
  */
54
-export type State = {
52
+export interface IState {
55 53
 
56 54
     /**
57 55
      * Details about the broadcasts available for use for the logged in Google
58 56
      * user's YouTube account.
59 57
      */
60
-    broadcasts: ?Array<Object>,
58
+    broadcasts?: Array<any>;
61 59
 
62 60
     /**
63 61
      * The error type, as provided by Google, for the most recent error
64 62
      * encountered by the Google API.
65 63
      */
66
-    errorType: ?string,
64
+    errorType?: string;
67 65
 
68 66
     /**
69 67
      * The boundStreamID of the broadcast currently selected in the broadcast
70 68
      * dropdown.
71 69
      */
72
-    selectedBoundStreamID: ?string,
70
+    selectedBoundStreamID?: string;
73 71
 
74 72
     /**
75 73
      * The selected or entered stream key to use for YouTube live streaming.
76 74
      */
77
-    streamKey: string
78
-};
75
+    streamKey: string;
76
+}
79 77
 
80 78
 /**
81 79
  * Implements an abstract class for the StartLiveStreamDialog on both platforms.
@@ -84,8 +82,8 @@ export type State = {
84 82
  * but the abstraction of its properties are already present in this abstract
85 83
  * class.
86 84
  */
87
-export default class AbstractStartLiveStreamDialog<P: Props>
88
-    extends Component<P, State> {
85
+export default class AbstractStartLiveStreamDialog<P extends IProps>
86
+    extends Component<P, IState> {
89 87
     _isMounted: boolean;
90 88
 
91 89
     /**
@@ -139,8 +137,6 @@ export default class AbstractStartLiveStreamDialog<P: Props>
139 137
         this._isMounted = false;
140 138
     }
141 139
 
142
-    _onCancel: () => boolean;
143
-
144 140
     /**
145 141
      * Invokes the passed in {@link onCancel} callback and closes
146 142
      * {@code StartLiveStreamDialog}.
@@ -163,9 +159,7 @@ export default class AbstractStartLiveStreamDialog<P: Props>
163 159
      * @private
164 160
      * @returns {Promise}
165 161
      */
166
-    _onGetYouTubeBroadcasts: () => Promise<*>;
167
-
168
-    _onStreamKeyChange: string => void;
162
+    _onGetYouTubeBroadcasts: () => Promise<any>;
169 163
 
170 164
     /**
171 165
      * Callback invoked to update the {@code StartLiveStreamDialog} component's
@@ -175,15 +169,13 @@ export default class AbstractStartLiveStreamDialog<P: Props>
175 169
      * @private
176 170
      * @returns {void}
177 171
      */
178
-    _onStreamKeyChange(streamKey) {
172
+    _onStreamKeyChange(streamKey: string) {
179 173
         this._setStateIfMounted({
180 174
             streamKey,
181 175
             selectedBoundStreamID: undefined
182 176
         });
183 177
     }
184 178
 
185
-    _onSubmit: () => boolean;
186
-
187 179
     /**
188 180
      * Invokes the passed in {@link onSubmit} callback with the entered stream
189 181
      * key, and then closes {@code StartLiveStreamDialog}.
@@ -204,10 +196,10 @@ export default class AbstractStartLiveStreamDialog<P: Props>
204 196
         let selectedBroadcastID = null;
205 197
 
206 198
         if (selectedBoundStreamID) {
207
-            const selectedBroadcast = broadcasts && broadcasts.find(
199
+            const selectedBroadcast = broadcasts?.find(
208 200
                 broadcast => broadcast.boundStreamID === selectedBoundStreamID);
209 201
 
210
-            selectedBroadcastID = selectedBroadcast && selectedBroadcast.id;
202
+            selectedBroadcastID = selectedBroadcast?.id;
211 203
         }
212 204
 
213 205
         sendAnalytics(
@@ -231,7 +223,7 @@ export default class AbstractStartLiveStreamDialog<P: Props>
231 223
      * @private
232 224
      * @returns {void}
233 225
      */
234
-    _setStateIfMounted(newState) {
226
+    _setStateIfMounted(newState: IState) {
235 227
         if (this._isMounted) {
236 228
             this.setState(newState);
237 229
         }
@@ -249,7 +241,7 @@ export default class AbstractStartLiveStreamDialog<P: Props>
249 241
  *     _streamKey: string
250 242
  * }}
251 243
  */
252
-export function _mapStateToProps(state: Object) {
244
+export function _mapStateToProps(state: IReduxState) {
253 245
     return {
254 246
         _conference: state['features/base/conference'].conference,
255 247
         _googleAPIState: state['features/google-api'].googleAPIState,

react/features/recording/components/LiveStream/AbstractStopLiveStreamDialog.js → react/features/recording/components/LiveStream/AbstractStopLiveStreamDialog.ts Переглянути файл

@@ -1,11 +1,10 @@
1
-// @flow
2
-
3 1
 import { Component } from 'react';
2
+import { WithTranslation } from 'react-i18next';
4 3
 
5
-import {
6
-    createLiveStreamingDialogEvent,
7
-    sendAnalytics
8
-} from '../../../analytics';
4
+import { createLiveStreamingDialogEvent } from '../../../analytics/AnalyticsEvents';
5
+import { sendAnalytics } from '../../../analytics/functions';
6
+import { IReduxState } from '../../../app/types';
7
+import { IJitsiConference } from '../../../base/conference/reducer';
9 8
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
10 9
 import { getActiveSession } from '../../functions';
11 10
 
@@ -13,23 +12,18 @@ import { getActiveSession } from '../../functions';
13 12
  * The type of the React {@code Component} props of
14 13
  * {@link StopLiveStreamDialog}.
15 14
  */
16
-type Props = {
15
+interface IProps extends WithTranslation {
17 16
 
18 17
     /**
19 18
      * The {@code JitsiConference} for the current conference.
20 19
      */
21
-    _conference: Object,
22
-
23
-    /**
24
-     * The redux representation of the live stremaing to be stopped.
25
-     */
26
-    _session: Object,
20
+    _conference: IJitsiConference;
27 21
 
28 22
     /**
29
-     * Invoked to obtain translated strings.
23
+     * The redux representation of the live streaming to be stopped.
30 24
      */
31
-    t: Function
32
-};
25
+    _session: { id: string; };
26
+}
33 27
 
34 28
 /**
35 29
  * A React Component for confirming the participant wishes to stop the currently
@@ -37,22 +31,20 @@ type Props = {
37 31
  *
38 32
  * @augments Component
39 33
  */
40
-export default class AbstractStopLiveStreamDialog extends Component<Props> {
34
+export default class AbstractStopLiveStreamDialog extends Component<IProps> {
41 35
     /**
42 36
      * Initializes a new {@code StopLiveStreamDialog} instance.
43 37
      *
44 38
      * @param {Object} props - The read-only properties with which the new
45 39
      * instance is to be initialized.
46 40
      */
47
-    constructor(props: Props) {
41
+    constructor(props: IProps) {
48 42
         super(props);
49 43
 
50 44
         // Bind event handler so it is only bound once for every instance.
51 45
         this._onSubmit = this._onSubmit.bind(this);
52 46
     }
53 47
 
54
-    _onSubmit: () => boolean;
55
-
56 48
     /**
57 49
      * Callback invoked when stopping of live streaming is confirmed.
58 50
      *
@@ -83,7 +75,7 @@ export default class AbstractStopLiveStreamDialog extends Component<Props> {
83 75
  *     _session: Object
84 76
  * }}
85 77
  */
86
-export function _mapStateToProps(state: Object) {
78
+export function _mapStateToProps(state: IReduxState) {
87 79
     return {
88 80
         _conference: state['features/base/conference'].conference,
89 81
         _session: getActiveSession(state, JitsiRecordingConstants.mode.STREAM)

react/features/recording/components/LiveStream/AbstractStreamKeyForm.js → react/features/recording/components/LiveStream/AbstractStreamKeyForm.ts Переглянути файл

@@ -1,64 +1,65 @@
1
-// @flow
2
-
1
+import { DebouncedFunc } from 'lodash';
3 2
 import debounce from 'lodash/debounce';
4 3
 import { Component } from 'react';
4
+import { WithTranslation } from 'react-i18next';
5
+
6
+import { IReduxState } from '../../../app/types';
5 7
 
6 8
 import { getLiveStreaming } from './functions';
7 9
 
8 10
 
9 11
 export type LiveStreaming = {
10
-    enabled: boolean,
11
-    helpLink: string, // Documentation reference for the live streaming feature.
12
-    termsLink: string, // Terms link
13
-    dataPrivacyLink: string, // Data privacy link
14
-    validatorRegExpString: string // RegExp string that validates the stream key input field
15
-}
12
+
13
+    // Terms link
14
+    dataPrivacyLink: string;
15
+    enabled: boolean;
16
+    helpLink: string;
17
+
18
+    // Documentation reference for the live streaming feature.
19
+    termsLink: string; // Data privacy link
20
+    validatorRegExpString: string; // RegExp string that validates the stream key input field
21
+};
16 22
 
17 23
 export type LiveStreamingProps = {
18
-    enabled: boolean,
19
-    helpURL: string,
20
-    termsURL: string,
21
-    dataPrivacyURL: string,
22
-    streamLinkRegexp: RegExp
23
-}
24
+    dataPrivacyURL: string;
25
+    enabled: boolean;
26
+    helpURL: string;
27
+    streamLinkRegexp: RegExp;
28
+    termsURL: string;
29
+};
24 30
 
25 31
 /**
26 32
  * The props of the component.
27 33
  */
28
-export type Props = {
34
+export interface IProps extends WithTranslation {
29 35
 
30 36
     /**
31 37
      * The live streaming dialog properties.
32 38
      */
33
-    _liveStreaming: LiveStreamingProps,
39
+    _liveStreaming: LiveStreamingProps;
34 40
 
35 41
     /**
36 42
      * Callback invoked when the entered stream key has changed.
37 43
      */
38
-    onChange: Function,
39
-
40
-    /**
41
-     * Invoked to obtain translated strings.
42
-     */
43
-    t: Function,
44
+    onChange: Function;
44 45
 
45 46
     /**
46 47
      * The stream key value to display as having been entered so far.
47 48
      */
48
-    value: string
49
-};
49
+    value: string;
50
+}
50 51
 
51 52
 /**
52 53
  * The state of the component.
53 54
  */
54
-type State = {
55
+interface IState {
55 56
 
56 57
     /**
57 58
      * Whether or not to show the warnings that the passed in value seems like
58 59
      * an improperly formatted stream key.
59 60
      */
60
-    showValidationError: boolean
61
-};
61
+    showValidationError: boolean;
62
+}
62 63
 
63 64
 /**
64 65
  * An abstract React Component for entering a key for starting a YouTube live
@@ -66,10 +67,10 @@ type State = {
66 67
  *
67 68
  * @augments Component
68 69
  */
69
-export default class AbstractStreamKeyForm<P: Props>
70
-    extends Component<P, State> {
70
+export default class AbstractStreamKeyForm<P extends IProps>
71
+    extends Component<P, IState> {
71 72
 
72
-    _debouncedUpdateValidationErrorVisibility: Function;
73
+    _debouncedUpdateValidationErrorVisibility: DebouncedFunc<() => void>;
73 74
 
74 75
     /**
75 76
      * Constructor for the component.
@@ -114,8 +115,6 @@ export default class AbstractStreamKeyForm<P: Props>
114 115
         this._debouncedUpdateValidationErrorVisibility.cancel();
115 116
     }
116 117
 
117
-    _onInputChange: Object => void;
118
-
119 118
     /**
120 119
      * Callback invoked when the value of the input field has updated through
121 120
      * user input. This forwards the value (string only, even if it was a dom
@@ -126,7 +125,7 @@ export default class AbstractStreamKeyForm<P: Props>
126 125
      * @private
127 126
      * @returns {void}
128 127
      */
129
-    _onInputChange(change) {
128
+    _onInputChange(change: any) {
130 129
         const value = typeof change === 'object' ? change.target.value : change;
131 130
 
132 131
         this.props.onChange(value);
@@ -174,7 +173,7 @@ export default class AbstractStreamKeyForm<P: Props>
174 173
  *     _liveStreaming: LiveStreamingProps
175 174
  * }}
176 175
  */
177
-export function _mapStateToProps(state: Object) {
176
+export function _mapStateToProps(state: IReduxState) {
178 177
     return {
179 178
         _liveStreaming: getLiveStreaming(state)
180 179
     };

react/features/recording/components/LiveStream/functions.js → react/features/recording/components/LiveStream/functions.ts Переглянути файл

@@ -1,3 +1,5 @@
1
+import { IReduxState } from '../../../app/types';
2
+
1 3
 import {
2 4
     FOUR_GROUPS_DASH_SEPARATED,
3 5
     GOOGLE_PRIVACY_POLICY,
@@ -11,7 +13,7 @@ import {
11 13
  * @param {Object} state - The global state.
12 14
  * @returns {LiveStreaming}
13 15
  */
14
-export function getLiveStreaming(state: Object) {
16
+export function getLiveStreaming(state: IReduxState) {
15 17
     const { liveStreaming = {} } = state['features/base/config'];
16 18
 
17 19
     const regexp = liveStreaming.validatorRegExpString

react/features/shared-video/components/web/AbstractVideoManager.js → react/features/shared-video/components/web/AbstractVideoManager.ts Переглянути файл

@@ -1,17 +1,19 @@
1
-/* @flow */
2 1
 /* eslint-disable no-invalid-this */
2
+// @ts-ignore
3 3
 import Logger from '@jitsi/logger';
4 4
 import throttle from 'lodash/throttle';
5 5
 import { PureComponent } from 'react';
6 6
 
7
-import { createSharedVideoEvent as createEvent, sendAnalytics } from '../../../analytics';
8
-import { getCurrentConference } from '../../../base/conference';
9
-import { MEDIA_TYPE } from '../../../base/media';
10
-import { getLocalParticipant } from '../../../base/participants';
11
-import { isLocalTrackMuted } from '../../../base/tracks';
12
-import { NOTIFICATION_TIMEOUT_TYPE } from '../../../notifications';
7
+import { createSharedVideoEvent as createEvent } from '../../../analytics/AnalyticsEvents';
8
+import { sendAnalytics } from '../../../analytics/functions';
9
+import { IReduxState } from '../../../app/types';
10
+import { getCurrentConference } from '../../../base/conference/functions';
11
+import { MEDIA_TYPE } from '../../../base/media/constants';
12
+import { getLocalParticipant } from '../../../base/participants/functions';
13
+import { isLocalTrackMuted } from '../../../base/tracks/functions';
13 14
 import { showWarningNotification } from '../../../notifications/actions';
14
-import { dockToolbox } from '../../../toolbox/actions.web';
15
+import { NOTIFICATION_TIMEOUT_TYPE } from '../../../notifications/constants';
16
+import { dockToolbox } from '../../../toolbox/actions';
15 17
 import { muteLocal } from '../../../video-menu/actions.any';
16 18
 import { setSharedVideoStatus, stopSharedVideo } from '../../actions.any';
17 19
 import { PLAYBACK_STATUSES } from '../../constants';
@@ -19,113 +21,115 @@ import { PLAYBACK_STATUSES } from '../../constants';
19 21
 const logger = Logger.getLogger(__filename);
20 22
 
21 23
 /**
22
- * Return true if the diffenrece between the two timees is larger than 5.
24
+ * Return true if the difference between the two times is larger than 5.
23 25
  *
24 26
  * @param {number} newTime - The current time.
25 27
  * @param {number} previousTime - The previous time.
26 28
  * @private
27 29
  * @returns {boolean}
28 30
 */
29
-function shouldSeekToPosition(newTime, previousTime) {
31
+function shouldSeekToPosition(newTime: number, previousTime: number) {
30 32
     return Math.abs(newTime - previousTime) > 5;
31 33
 }
32 34
 
33 35
 /**
34 36
  * The type of the React {@link PureComponent} props of {@link AbstractVideoManager}.
35 37
  */
36
-export type Props = {
38
+export interface IProps {
37 39
 
38 40
     /**
39
-     * The current coference.
41
+     * The current conference.
40 42
      */
41
-    _conference: Object,
43
+    _conference: Object;
42 44
 
43 45
     /**
44 46
      * Warning that indicates an incorrect video url.
45 47
      */
46
-    _displayWarning: Function,
48
+    _displayWarning: Function;
47 49
 
48 50
     /**
49 51
      * Docks the toolbox.
50 52
      */
51
-    _dockToolbox: Function,
52
-
53
-    /**
54
-     * Action to stop video sharing.
55
-    */
56
-    _stopSharedVideo: Function,
53
+    _dockToolbox: Function;
57 54
 
58 55
     /**
59 56
      * Indicates whether the local audio is muted.
60 57
     */
61
-    _isLocalAudioMuted: boolean,
58
+    _isLocalAudioMuted: boolean;
62 59
 
63 60
     /**
64 61
      * Is the video shared by the local user.
65 62
      *
66 63
      * @private
67 64
      */
68
-    _isOwner: boolean,
65
+    _isOwner: boolean;
69 66
 
70 67
     /**
71
-     * Store flag for muted state.
68
+     * Mutes local audio track.
72 69
      */
73
-    _muted: boolean,
70
+    _muteLocal: Function;
74 71
 
75 72
     /**
76
-     * Mutes local audio track.
73
+     * Store flag for muted state.
77 74
      */
78
-    _muteLocal: Function,
75
+    _muted: boolean;
79 76
 
80 77
     /**
81 78
      * The shared video owner id.
82 79
      */
83
-    _ownerId: string,
80
+    _ownerId: string;
84 81
 
85 82
     /**
86 83
      * Updates the shared video status.
87 84
      */
88
-    _setSharedVideoStatus: Function,
85
+    _setSharedVideoStatus: Function;
89 86
 
90 87
     /**
91 88
      * The shared video status.
92 89
      */
93
-     _status: string,
90
+    _status: string;
91
+
92
+    /**
93
+     * Action to stop video sharing.
94
+    */
95
+    _stopSharedVideo: Function;
94 96
 
95 97
     /**
96 98
      * Seek time in seconds.
97 99
      *
98 100
      */
99
-    _time: number,
101
+    _time: number;
100 102
 
101 103
     /**
102 104
      * The video url.
103 105
      */
104
-     _videoUrl: string,
106
+    _videoUrl: string;
105 107
 
106
-     /**
108
+    /**
107 109
       * The video id.
108 110
       */
109
-     videoId: string
111
+    videoId: string;
110 112
 }
111 113
 
112 114
 /**
113 115
  * Manager of shared video.
114 116
  */
115
-class AbstractVideoManager extends PureComponent<Props> {
117
+class AbstractVideoManager extends PureComponent<IProps> {
116 118
     throttledFireUpdateSharedVideoEvent: Function;
117 119
 
118 120
     /**
119 121
      * Initializes a new instance of AbstractVideoManager.
120 122
      *
123
+     * @param {IProps} props - Component props.
121 124
      * @returns {void}
122 125
      */
123
-    constructor() {
124
-        super();
126
+    constructor(props: IProps) {
127
+        super(props);
125 128
 
126 129
         this.throttledFireUpdateSharedVideoEvent = throttle(this.fireUpdateSharedVideoEvent.bind(this), 5000);
127 130
 
128 131
         // selenium tests handler
132
+        // @ts-ignore
129 133
         window._sharedVideoPlayer = this;
130 134
     }
131 135
 
@@ -144,7 +148,7 @@ class AbstractVideoManager extends PureComponent<Props> {
144 148
      *
145 149
      * @inheritdoc
146 150
      */
147
-    componentDidUpdate(prevProps: Props) {
151
+    componentDidUpdate(prevProps: IProps) {
148 152
         const { _videoUrl } = this.props;
149 153
 
150 154
         if (prevProps._videoUrl !== _videoUrl) {
@@ -212,7 +216,7 @@ class AbstractVideoManager extends PureComponent<Props> {
212 216
      * @param {Object|undefined} e - The error returned by the API or none.
213 217
      * @returns {void}
214 218
      */
215
-    onError(e) {
219
+    onError(e: any) {
216 220
         logger.error('Error in the video player', e?.data,
217 221
             e?.data ? 'Check error code at https://developers.google.com/youtube/iframe_api_reference#onError' : '');
218 222
         this.props._stopSharedVideo();
@@ -347,7 +351,7 @@ class AbstractVideoManager extends PureComponent<Props> {
347 351
     /**
348 352
      * Indicates the playback state of the video.
349 353
      */
350
-    getPlaybackStatus: () => boolean;
354
+    getPlaybackStatus: () => string;
351 355
 
352 356
     /**
353 357
      * Indicates whether the video is muted.
@@ -397,9 +401,9 @@ export default AbstractVideoManager;
397 401
  * Maps part of the Redux store to the props of this component.
398 402
  *
399 403
  * @param {Object} state - The Redux state.
400
- * @returns {Props}
404
+ * @returns {IProps}
401 405
  */
402
-export function _mapStateToProps(state: Object) {
406
+export function _mapStateToProps(state: IReduxState) {
403 407
     const { ownerId, status, time, videoUrl, muted } = state['features/shared-video'];
404 408
     const localParticipant = getLocalParticipant(state);
405 409
     const _isLocalAudioMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO);
@@ -407,7 +411,7 @@ export function _mapStateToProps(state: Object) {
407 411
     return {
408 412
         _conference: getCurrentConference(state),
409 413
         _isLocalAudioMuted,
410
-        _isOwner: ownerId === localParticipant.id,
414
+        _isOwner: ownerId === localParticipant?.id,
411 415
         _muted: muted,
412 416
         _ownerId: ownerId,
413 417
         _status: status,
@@ -420,25 +424,25 @@ export function _mapStateToProps(state: Object) {
420 424
  * Maps part of the props of this component to Redux actions.
421 425
  *
422 426
  * @param {Function} dispatch - The Redux dispatch function.
423
- * @returns {Props}
427
+ * @returns {IProps}
424 428
  */
425
-export function _mapDispatchToProps(dispatch: Function): $Shape<Props> {
429
+export function _mapDispatchToProps(dispatch: Function) {
426 430
     return {
427 431
         _displayWarning: () => {
428 432
             dispatch(showWarningNotification({
429 433
                 titleKey: 'dialog.shareVideoLinkError'
430 434
             }, NOTIFICATION_TIMEOUT_TYPE.LONG));
431 435
         },
432
-        _dockToolbox: value => {
436
+        _dockToolbox: (value: boolean) => {
433 437
             dispatch(dockToolbox(value));
434 438
         },
435 439
         _stopSharedVideo: () => {
436 440
             dispatch(stopSharedVideo());
437 441
         },
438
-        _muteLocal: value => {
442
+        _muteLocal: (value: boolean) => {
439 443
             dispatch(muteLocal(value, MEDIA_TYPE.AUDIO));
440 444
         },
441
-        _setSharedVideoStatus: ({ videoUrl, status, time, ownerId, muted }) => {
445
+        _setSharedVideoStatus: ({ videoUrl, status, time, ownerId, muted }: any) => {
442 446
             dispatch(setSharedVideoStatus({
443 447
                 videoUrl,
444 448
                 status,

react/features/welcome/components/AbstractWelcomePage.js → react/features/welcome/components/AbstractWelcomePage.ts Переглянути файл

@@ -1,69 +1,69 @@
1
-// @flow
2
-
1
+// @ts-expect-error
3 2
 import { generateRoomWithoutSeparator } from '@jitsi/js-utils/random';
4 3
 import { Component } from 'react';
5
-import type { Dispatch } from 'redux';
6 4
 
7
-import { createWelcomePageEvent, sendAnalytics } from '../../analytics';
5
+import { createWelcomePageEvent } from '../../analytics/AnalyticsEvents';
6
+import { sendAnalytics } from '../../analytics/functions';
8 7
 import { appNavigate } from '../../app/actions';
8
+import { IReduxState, IStore } from '../../app/types';
9 9
 import { IDeeplinkingConfig } from '../../base/config/configType';
10 10
 import isInsecureRoomName from '../../base/util/isInsecureRoomName';
11
-import { isCalendarEnabled } from '../../calendar-sync';
11
+import { isCalendarEnabled } from '../../calendar-sync/functions';
12 12
 import { isRecentListEnabled } from '../../recent-list/functions';
13 13
 
14 14
 /**
15 15
  * {@code AbstractWelcomePage}'s React {@code Component} prop types.
16 16
  */
17
-export type Props = {
17
+export interface IProps {
18 18
 
19 19
     /**
20 20
      * Whether the calendar functionality is enabled or not.
21 21
      */
22
-    _calendarEnabled: boolean,
22
+    _calendarEnabled: boolean;
23 23
 
24 24
     /**
25 25
      * The deeplinking config.
26 26
      */
27
-    _deeplinkingCfg: IDeeplinkingConfig,
27
+    _deeplinkingCfg: IDeeplinkingConfig;
28 28
 
29 29
     /**
30 30
      * Whether the insecure room name functionality is enabled or not.
31 31
      */
32
-    _enableInsecureRoomNameWarning: boolean,
32
+    _enableInsecureRoomNameWarning: boolean;
33 33
 
34 34
     /**
35 35
      * URL for the moderated rooms microservice, if available.
36 36
      */
37
-    _moderatedRoomServiceUrl: ?string,
37
+    _moderatedRoomServiceUrl?: string;
38 38
 
39 39
     /**
40 40
      * Whether the recent list is enabled.
41 41
      */
42
-    _recentListEnabled: Boolean,
42
+    _recentListEnabled: Boolean;
43 43
 
44 44
     /**
45 45
      * Room name to join to.
46 46
      */
47
-    _room: string,
47
+    _room: string;
48 48
 
49 49
     /**
50 50
      * The current settings.
51 51
      */
52
-    _settings: Object,
52
+    _settings: Object;
53 53
 
54 54
     /**
55 55
      * The Redux dispatch Function.
56 56
      */
57
-    dispatch: Dispatch<any>
58
-};
57
+    dispatch: IStore['dispatch'];
58
+}
59 59
 
60 60
 /**
61 61
  * Base (abstract) class for container component rendering the welcome page.
62 62
  *
63 63
  * @abstract
64 64
  */
65
-export class AbstractWelcomePage<P: Props> extends Component<P, *> {
66
-    _mounted: ?boolean;
65
+export class AbstractWelcomePage<P extends IProps> extends Component<P> {
66
+    _mounted: boolean | undefined;
67 67
 
68 68
     /**
69 69
      * Save room name into component's local state.
@@ -71,7 +71,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
71 71
      * @type {Object}
72 72
      * @property {number|null} animateTimeoutId - Identifier of the letter
73 73
      * animation timeout.
74
-     * @property {string} generatedRoomname - Automatically generated room name.
74
+     * @property {string} generatedRoomName - Automatically generated room name.
75 75
      * @property {string} room - Room name.
76 76
      * @property {string} roomPlaceholder - Room placeholder that's used as a
77 77
      * placeholder for input.
@@ -80,7 +80,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
80 80
      */
81 81
     state = {
82 82
         animateTimeoutId: undefined,
83
-        generatedRoomname: '',
83
+        generatedRoomName: '',
84 84
         insecureRoomName: false,
85 85
         joining: false,
86 86
         room: '',
@@ -98,12 +98,12 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
98 98
         super(props);
99 99
 
100 100
         // Bind event handlers so they are only bound once per instance.
101
-        this._animateRoomnameChanging
102
-            = this._animateRoomnameChanging.bind(this);
101
+        this._animateRoomNameChanging
102
+            = this._animateRoomNameChanging.bind(this);
103 103
         this._onJoin = this._onJoin.bind(this);
104 104
         this._onRoomChange = this._onRoomChange.bind(this);
105 105
         this._renderInsecureRoomNameWarning = this._renderInsecureRoomNameWarning.bind(this);
106
-        this._updateRoomname = this._updateRoomname.bind(this);
106
+        this._updateRoomName = this._updateRoomName.bind(this);
107 107
     }
108 108
 
109 109
     /**
@@ -128,8 +128,6 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
128 128
         this._mounted = false;
129 129
     }
130 130
 
131
-    _animateRoomnameChanging: (string) => void;
132
-
133 131
     /**
134 132
      * Animates the changing of the room name.
135 133
      *
@@ -138,7 +136,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
138 136
      * @private
139 137
      * @returns {void}
140 138
      */
141
-    _animateRoomnameChanging(word: string) {
139
+    _animateRoomNameChanging(word: string) {
142 140
         let animateTimeoutId;
143 141
         const roomPlaceholder = this.state.roomPlaceholder + word.substr(0, 1);
144 142
 
@@ -146,7 +144,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
146 144
             animateTimeoutId
147 145
                 = setTimeout(
148 146
                     () => {
149
-                        this._animateRoomnameChanging(
147
+                        this._animateRoomNameChanging(
150 148
                             word.substring(1, word.length));
151 149
                     },
152 150
                     70);
@@ -164,8 +162,8 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
164 162
      * @returns {void}
165 163
      */
166 164
     _clearTimeouts() {
167
-        clearTimeout(this.state.animateTimeoutId);
168
-        clearTimeout(this.state.updateTimeoutId);
165
+        this.state.animateTimeoutId && clearTimeout(this.state.animateTimeoutId);
166
+        this.state.updateTimeoutId && clearTimeout(this.state.updateTimeoutId);
169 167
     }
170 168
 
171 169
     /**
@@ -173,9 +171,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
173 171
      *
174 172
      * @returns {ReactElement}
175 173
      */
176
-    _doRenderInsecureRoomNameWarning: () => React$Component<any>;
177
-
178
-    _onJoin: () => void;
174
+    _doRenderInsecureRoomNameWarning: () => React.Component<any>;
179 175
 
180 176
     /**
181 177
      * Handles joining. Either by clicking on 'Join' button
@@ -185,7 +181,7 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
185 181
      * @returns {void}
186 182
      */
187 183
     _onJoin() {
188
-        const room = this.state.room || this.state.generatedRoomname;
184
+        const room = this.state.room || this.state.generatedRoomName;
189 185
 
190 186
         sendAnalytics(
191 187
             createWelcomePageEvent('clicked', 'joinButton', {
@@ -206,8 +202,6 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
206 202
         }
207 203
     }
208 204
 
209
-    _onRoomChange: (string) => void;
210
-
211 205
     /**
212 206
      * Handles 'change' event for the room name text input field.
213 207
      *
@@ -223,8 +217,6 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
223 217
         });
224 218
     }
225 219
 
226
-    _renderInsecureRoomNameWarning: () => React$Component<any>;
227
-
228 220
     /**
229 221
      * Renders the insecure room name warning if needed.
230 222
      *
@@ -238,8 +230,6 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
238 230
         return null;
239 231
     }
240 232
 
241
-    _updateRoomname: () => void;
242
-
243 233
     /**
244 234
      * Triggers the generation of a new room name and initiates an animation of
245 235
      * its changing.
@@ -247,19 +237,19 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
247 237
      * @protected
248 238
      * @returns {void}
249 239
      */
250
-    _updateRoomname() {
251
-        const generatedRoomname = generateRoomWithoutSeparator();
240
+    _updateRoomName() {
241
+        const generatedRoomName = generateRoomWithoutSeparator();
252 242
         const roomPlaceholder = '';
253
-        const updateTimeoutId = setTimeout(this._updateRoomname, 10000);
243
+        const updateTimeoutId = setTimeout(this._updateRoomName, 10000);
254 244
 
255 245
         this._clearTimeouts();
256 246
         this.setState(
257 247
             {
258
-                generatedRoomname,
248
+                generatedRoomName,
259 249
                 roomPlaceholder,
260 250
                 updateTimeoutId
261 251
             },
262
-            () => this._animateRoomnameChanging(generatedRoomname));
252
+            () => this._animateRoomNameChanging(generatedRoomName));
263 253
     }
264 254
 }
265 255
 
@@ -269,9 +259,9 @@ export class AbstractWelcomePage<P: Props> extends Component<P, *> {
269 259
  *
270 260
  * @param {Object} state - The redux state.
271 261
  * @protected
272
- * @returns {Props}
262
+ * @returns {IProps}
273 263
  */
274
-export function _mapStateToProps(state: Object) {
264
+export function _mapStateToProps(state: IReduxState) {
275 265
     return {
276 266
         _calendarEnabled: isCalendarEnabled(state),
277 267
         _deeplinkingCfg: state['features/base/config'].deeplinking || {},

Завантаження…
Відмінити
Зберегти