fix(lint) tame Flow

This commit is contained in:
Saúl Ibarra Corretgé 2022-01-07 11:54:42 +01:00 committed by Saúl Ibarra Corretgé
parent 90321ca016
commit ab3d2160c9
23 changed files with 118 additions and 92 deletions

View File

@ -2,14 +2,15 @@
import { makeStyles } from '@material-ui/core'; import { makeStyles } from '@material-ui/core';
import React from 'react'; import React from 'react';
import ContextMenuItem, { type Props as Action } from './ContextMenuItem'; import ContextMenuItem from './ContextMenuItem';
type Props = { type Props = {
/** /**
* List of actions in this group. * List of actions in this group.
*/ */
actions?: Array<Action>, actions?: Array<Object>,
/** /**
* The children of the component. * The children of the component.

View File

@ -4,12 +4,7 @@ import { useCallback, useRef, useState } from 'react';
import { findAncestorByClass } from '../../../participants-pane/functions'; import { findAncestorByClass } from '../../../participants-pane/functions';
type NullProto = { type RaiseContext = {|
[key: string]: any,
__proto__: null
};
type RaiseContext = NullProto | {|
/** /**
* Target elements against which positioning calculations are made. * Target elements against which positioning calculations are made.
@ -22,7 +17,7 @@ type RaiseContext = NullProto | {|
entity?: string | Object, entity?: string | Object,
|}; |};
const initialState = Object.freeze(Object.create(null)); const initialState = Object.freeze({});
const useContextMenu = () => { const useContextMenu = () => {
const [ raiseContext, setRaiseContext ] = useState < RaiseContext >(initialState); const [ raiseContext, setRaiseContext ] = useState < RaiseContext >(initialState);

View File

@ -70,7 +70,8 @@ class InputDialog extends BaseDialog<Props, State> {
super(props); super(props);
this.state = { this.state = {
fieldValue: props.initialValue fieldValue: props.initialValue,
submitting: false
}; };
this._onChangeText = this._onChangeText.bind(this); this._onChangeText = this._onChangeText.bind(this);

View File

@ -1,6 +1,5 @@
// @flow // @flow
import type { PanResponderInstance } from 'PanResponder';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { PanResponder, PixelRatio, View } from 'react-native'; import { PanResponder, PixelRatio, View } from 'react-native';
import { type Dispatch } from 'redux'; import { type Dispatch } from 'redux';
@ -119,12 +118,12 @@ class VideoTransform extends Component<Props, State> {
/** /**
* The gesture handler object. * The gesture handler object.
*/ */
gestureHandlers: PanResponderInstance; gestureHandlers: Object;
/** /**
* The initial distance of the fingers on pinch start. * The initial distance of the fingers on pinch start.
*/ */
initialDistance: number; initialDistance: ?number;
/** /**
* The initial position of the finger on touch start. * The initial position of the finger on touch start.
@ -628,7 +627,10 @@ class VideoTransform extends Component<Props, State> {
this._onGesture('press'); this._onGesture('press');
} }
delete this.initialDistance; delete this.initialDistance;
delete this.initialPosition; this.initialPosition = {
x: 0,
y: 0
};
} }
_onStartShouldSetPanResponder: () => boolean; _onStartShouldSetPanResponder: () => boolean;

View File

@ -17,7 +17,7 @@ export type MediaType = 'audio' | 'video' | 'presenter';
* *
* @enum {string} * @enum {string}
*/ */
export const MEDIA_TYPE: { AUDIO: MediaType, PRESENTER: MediaType, VIDEO: MediaType} = { export const MEDIA_TYPE = {
AUDIO: 'audio', AUDIO: 'audio',
PRESENTER: 'presenter', PRESENTER: 'presenter',
VIDEO: 'video' VIDEO: 'video'

View File

@ -1,6 +1,6 @@
// @flow // @flow
import type { ComponentType, Element } from 'react'; import type { ComponentType } from 'react';
/** /**
* Item data for <tt>NavigateSectionList</tt>. * Item data for <tt>NavigateSectionList</tt>.
@ -73,7 +73,7 @@ export type Section = {
keyExtractor?: (item: Object) => string, keyExtractor?: (item: Object) => string,
renderItem?: ?(info: Object) => ?Element<any> renderItem?: ?(info: Object) => null | React$Element<any>
} }

View File

@ -40,6 +40,8 @@ export default class Container<P: Props> extends AbstractContainer<P> {
touchFeedback = Boolean(onClick || onLongPress), touchFeedback = Boolean(onClick || onLongPress),
underlayColor, underlayColor,
visible = true, visible = true,
// $FlowExpectedError
...props ...props
} = this.props; } = this.props;

View File

@ -1,11 +1,11 @@
/* @flow */ /* @flow */
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import { ActivityIndicator } from 'react-native'; import { ActivityIndicator } from 'react-native';
import { ColorPalette } from '../../../styles'; import { ColorPalette } from '../../../styles';
type Props = { type Props = {|
/** /**
* The color of the spinner. * The color of the spinner.
@ -17,14 +17,14 @@ type Props = {
* prop of the native component. * prop of the native component.
*/ */
size: 'large' | 'small' size: 'large' | 'small'
}; |};
/** /**
* An animated, large react-native {@link ActivityIndicator} which is considered * An animated, large react-native {@link ActivityIndicator} which is considered
* a suitable visualization of long-running processes with indeterminate amounts * a suitable visualization of long-running processes with indeterminate amounts
* of work to be done. * of work to be done.
*/ */
export default class LoadingIndicator extends Component<Props> { export default class LoadingIndicator extends PureComponent<Props> {
/** /**
* Implements React's {@link Component#render()}. * Implements React's {@link Component#render()}.
* *

View File

@ -1,33 +1,11 @@
// @flow import React, { PureComponent } from 'react';
import React, { Component, type Node } from 'react';
import { Modal as NativeModal } from 'react-native'; import { Modal as NativeModal } from 'react-native';
/**
* Type of the props of the component.
*/
type Props = {
/**
* Children of the component.
*/
children: Node
/**
* NOTE: We pass through all props to {@code react-native#Modal} that are
* passed to this component, so we don't list them all here, as that would
* be an unnecessary duplication and probably an unmaintained list after a
* while.
*
* See list: https://facebook.github.io/react-native/docs/modal.
*/
};
/** /**
* Implements a generic Modal (using the built-in Modal component) to share * Implements a generic Modal (using the built-in Modal component) to share
* behaviour across modals in the app. * behavior across modals in the app.
*/ */
export default class Modal extends Component<Props> { export default class Modal extends PureComponent {
/** /**
* Implements {@code Component#render}. * Implements {@code Component#render}.
@ -35,6 +13,7 @@ export default class Modal extends Component<Props> {
* @inheritdoc * @inheritdoc
*/ */
render() { render() {
// eslint-disable-next-line react/prop-types
const { children, ...props } = this.props; const { children, ...props } = this.props;
return ( return (

View File

@ -92,6 +92,20 @@ class PagedList extends Component<Props, State> {
render() { render() {
const { disabled } = this.props; const { disabled } = this.props;
const pages = this.props.pages.filter(({ component }) => component); const pages = this.props.pages.filter(({ component }) => component);
let children;
if (pages.length > 1) {
children = this._renderPagedList(disabled);
} else {
children = React.createElement(
// $FlowExpectedError
/* type */ pages[0].component,
/* props */ {
disabled,
style: styles.pagedList
});
}
return ( return (
<View <View
@ -100,16 +114,9 @@ class PagedList extends Component<Props, State> {
disabled ? styles.pagedListContainerDisabled : null disabled ? styles.pagedListContainerDisabled : null
] }> ] }>
{ {
pages.length > 1
? this._renderPagedList(disabled)
: React.createElement(
// $FlowExpectedError // $FlowExpectedError
/* type */ pages[0].component, children
/* props */ {
disabled,
style: styles.pagedList
})
} }
</View> </View>
); );

View File

@ -3,7 +3,7 @@
import Toggle from '@atlaskit/toggle'; import Toggle from '@atlaskit/toggle';
import React, { Component } from 'react'; import React, { Component } from 'react';
type Props = { type Props = {|
/** /**
* ID of the toggle. * ID of the toggle.
@ -29,7 +29,7 @@ type Props = {
* The current value. * The current value.
*/ */
value: boolean value: boolean
}; |};
/** /**
* Renders a boolean input. * Renders a boolean input.

View File

@ -8,7 +8,7 @@ import { combineStyles } from '../../styles';
import type { Styles } from './AbstractToolboxItem'; import type { Styles } from './AbstractToolboxItem';
import ToolboxItem from './ToolboxItem'; import ToolboxItem from './ToolboxItem';
export type Props = { export type Props = {|
/** /**
* Function to be called after the click handler has been processed. * Function to be called after the click handler has been processed.
@ -20,6 +20,12 @@ export type Props = {
*/ */
buttonKey?: string, buttonKey?: string,
/**
* An extra class name to be added at the end of the element's class name
* in order to enable custom styling.
*/
customClass?: string,
/** /**
* Extra styles which will be applied in conjunction with `styles` or * Extra styles which will be applied in conjunction with `styles` or
* `toggledStyles` when the button is disabled;. * `toggledStyles` when the button is disabled;.
@ -61,7 +67,7 @@ export type Props = {
* Whether this button is visible or not. * Whether this button is visible or not.
*/ */
visible: boolean visible: boolean
}; |};
declare var APP: Object; declare var APP: Object;
@ -312,7 +318,6 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
const props = { const props = {
...this.props, ...this.props,
accessibilityLabel: this.accessibilityLabel, accessibilityLabel: this.accessibilityLabel,
disabled: this._isDisabled(),
elementAfter: this._getElementAfter(), elementAfter: this._getElementAfter(),
icon: this._getIcon(), icon: this._getIcon(),
label: this._getLabel(), label: this._getLabel(),

View File

@ -86,7 +86,7 @@ export type Props = {
/** /**
* True if the item is toggled, false otherwise. * True if the item is toggled, false otherwise.
*/ */
toggled: boolean, toggled: ?boolean,
/** /**
* The text to display in the tooltip. Used only on web. * The text to display in the tooltip. Used only on web.

View File

@ -74,7 +74,7 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {
<TouchableHighlight <TouchableHighlight
accessibilityLabel = { this.accessibilityLabel } accessibilityLabel = { this.accessibilityLabel }
accessibilityRole = 'button' accessibilityRole = 'button'
accessibilityState = {{ 'selected': toggled }} accessibilityState = {{ 'selected': Boolean(toggled) }}
disabled = { disabled } disabled = { disabled }
onPress = { onClick } onPress = { onClick }
style = { style } style = { style }

View File

@ -24,7 +24,7 @@ type Props = {
/** /**
* Target elements against which positioning calculations are made. * Target elements against which positioning calculations are made.
*/ */
offsetTarget: HTMLElement, offsetTarget: ?HTMLElement,
/** /**
* Callback for the mouse entering the component. * Callback for the mouse entering the component.

View File

@ -452,16 +452,16 @@ class RecordingController {
return result; return result;
} }
_changeState: (Symbol) => void; _changeState: (symbol) => void;
/** /**
* Changes the current state of {@code RecordingController}. * Changes the current state of {@code RecordingController}.
* *
* @private * @private
* @param {Symbol} newState - The new state. * @param {symbol} newState - The new state.
* @returns {void} * @returns {void}
*/ */
_changeState(newState: Symbol) { _changeState(newState: symbol) {
if (this._state !== newState) { if (this._state !== newState) {
logger.log(`state change: ${this._state.toString()} -> ` logger.log(`state change: ${this._state.toString()} -> `
+ `${newState.toString()}`); + `${newState.toString()}`);

View File

@ -11,6 +11,27 @@ import { setFatalError } from './actions';
declare var APP: Object; declare var APP: Object;
/**
* Error type. Basically like Error, but augmented with a recoverable property.
*/
type ErrorType = {|
/**
* Error message.
*/
message?: string,
/**
* Error name.
*/
name: string,
/**
* Indicates whether this event is recoverable or not.
*/
recoverable?: boolean
|};
/** /**
* List of errors that are not fatal (or handled differently) so then the overlays won't kick in. * List of errors that are not fatal (or handled differently) so then the overlays won't kick in.
*/ */
@ -74,16 +95,14 @@ StateListenerRegistry.register(
return configError || connectionError || conferenceError; return configError || connectionError || conferenceError;
}, },
/* listener */ (error, { dispatch, getState }) => { /* listener */ (error: ErrorType, { dispatch, getState }) => {
if (!error) { if (!error) {
return; return;
} }
if (typeof APP !== 'undefined') { if (typeof APP !== 'undefined') {
const parsedError = typeof error === 'string' ? { name: error } : error;
APP.API.notifyError({ APP.API.notifyError({
...parsedError, ...error,
...getErrorExtraInfo(getState, error) ...getErrorExtraInfo(getState, error)
}); });
} }

View File

@ -30,13 +30,7 @@ export type MediaState = 'DominantSpeaker' | 'Muted' | 'ForceMuted' | 'Unmuted'
/** /**
* Enum of possible participant media states. * Enum of possible participant media states.
*/ */
export const MEDIA_STATE: { export const MEDIA_STATE = {
DOMINANT_SPEAKER: MediaState,
MUTED: MediaState,
FORCE_MUTED: MediaState,
UNMUTED: MediaState,
NONE: MediaState,
} = {
DOMINANT_SPEAKER: 'DominantSpeaker', DOMINANT_SPEAKER: 'DominantSpeaker',
MUTED: 'Muted', MUTED: 'Muted',
FORCE_MUTED: 'ForceMuted', FORCE_MUTED: 'ForceMuted',
@ -92,6 +86,7 @@ export const AudioStateIcons: {[MediaState]: React$Element<any> | null} = {
* Icon mapping for possible participant video states. * Icon mapping for possible participant video states.
*/ */
export const VideoStateIcons = { export const VideoStateIcons = {
[MEDIA_STATE.DOMINANT_SPEAKER]: null,
[MEDIA_STATE.FORCE_MUTED]: ( [MEDIA_STATE.FORCE_MUTED]: (
<Icon <Icon
color = '#E04757' color = '#E04757'

View File

@ -68,23 +68,31 @@ function ReactionEmoji({ reaction, uid, index }: Props) {
transform: [ transform: [
{ translateY: animationVal.interpolate({ { translateY: animationVal.interpolate({
inputRange: [ 0, 0.70, 0.75, 1 ], inputRange: [ 0, 0.70, 0.75, 1 ],
// $FlowExpectedError
outputRange: [ 0, coordinates.topY * vh, coordinates.topY * vh, coordinates.bottomY * vh ] outputRange: [ 0, coordinates.topY * vh, coordinates.topY * vh, coordinates.bottomY * vh ]
}) })
}, { }, {
translateX: animationVal.interpolate({ translateX: animationVal.interpolate({
inputRange: [ 0, 0.70, 0.75, 1 ], inputRange: [ 0, 0.70, 0.75, 1 ],
// $FlowExpectedError
outputRange: [ 0, coordinates.topX, coordinates.topX, outputRange: [ 0, coordinates.topX, coordinates.topX,
coordinates.topX < 0 ? -coordinates.bottomX : coordinates.bottomX ] coordinates.topX < 0 ? -coordinates.bottomX : coordinates.bottomX ]
}) })
}, { }, {
scale: animationVal.interpolate({ scale: animationVal.interpolate({
inputRange: [ 0, 0.70, 0.75, 1 ], inputRange: [ 0, 0.70, 0.75, 1 ],
// $FlowExpectedError
outputRange: [ 0.6, 1.5, 1.5, 1 ] outputRange: [ 0.6, 1.5, 1.5, 1 ]
}) })
} }
], ],
opacity: animationVal.interpolate({ opacity: animationVal.interpolate({
inputRange: [ 0, 0.7, 0.75, 1 ], inputRange: [ 0, 0.7, 0.75, 1 ],
// $FlowExpectedError
outputRange: [ 1, 1, 1, 0 ] outputRange: [ 1, 1, 1, 0 ]
}) })
}}> }}>

View File

@ -143,7 +143,9 @@ function _mapStateToProps(state): Object {
_screensharing: isLocalVideoTrackDesktop(state), _screensharing: isLocalVideoTrackDesktop(state),
// TODO: this should work on iOS 12 too, but our trick to show the picker doesn't work. // TODO: this should work on iOS 12 too, but our trick to show the picker doesn't work.
visible: enabled && Platform.OS === 'ios' && Platform.Version.split('.')[0] >= 14 visible: enabled
&& Platform.OS === 'ios'
&& Number.parseInt(Platform.Version.split('.')[0], 10) >= 14
}; };
} }

View File

@ -84,16 +84,17 @@ function _setFullScreen(next, action) {
return result; return result;
} }
// $FlowFixMe
if (typeof document.exitFullscreen === 'function') { if (typeof document.exitFullscreen === 'function') {
document.exitFullscreen(); document.exitFullscreen();
// $FlowFixMe // $FlowExpectedError
} else if (typeof document.mozCancelFullScreen === 'function') { } else if (typeof document.mozCancelFullScreen === 'function') {
// $FlowExpectedError
document.mozCancelFullScreen(); document.mozCancelFullScreen();
// $FlowFixMe // $FlowExpectedError
} else if (typeof document.webkitExitFullscreen === 'function') { } else if (typeof document.webkitExitFullscreen === 'function') {
// $FlowExpectedError
document.webkitExitFullscreen(); document.webkitExitFullscreen();
} }
} }

View File

@ -200,15 +200,16 @@ function _updateReceiverVideoConstraints({ getState }) {
const sourceNameSignaling = getSourceNameSignalingFeatureFlag(state); const sourceNameSignaling = getSourceNameSignalingFeatureFlag(state);
const localParticipantId = getLocalParticipant(state).id; const localParticipantId = getLocalParticipant(state).id;
const receiverConstraints = { let receiverConstraints;
if (sourceNameSignaling) {
receiverConstraints = {
constraints: {}, constraints: {},
defaultConstraints: { 'maxHeight': VIDEO_QUALITY_LEVELS.NONE }, defaultConstraints: { 'maxHeight': VIDEO_QUALITY_LEVELS.NONE },
lastN, lastN,
...sourceNameSignaling ? { onStageSources: [] } : { onStageEndpoints: [] }, onStageSources: [],
...sourceNameSignaling ? { selectedSources: [] } : { selectedEndpoints: [] } selectedSources: []
}; };
if (sourceNameSignaling) {
const visibleRemoteTrackSourceNames = []; const visibleRemoteTrackSourceNames = [];
let largeVideoSourceName; let largeVideoSourceName;
@ -267,6 +268,14 @@ function _updateReceiverVideoConstraints({ getState }) {
} }
} else { } else {
receiverConstraints = {
constraints: {},
defaultConstraints: { 'maxHeight': VIDEO_QUALITY_LEVELS.NONE },
lastN,
onStageEndpoints: [],
selectedEndpoints: []
};
// Tile view. // Tile view.
// eslint-disable-next-line no-lonely-if // eslint-disable-next-line no-lonely-if
if (shouldDisplayTileView(state)) { if (shouldDisplayTileView(state)) {

View File

@ -34,7 +34,7 @@ export const blobToData = (blob: Blob): Promise<string> =>
new Promise(resolve => { new Promise(resolve => {
const reader = new FileReader(); const reader = new FileReader();
reader.onloadend = () => resolve(reader.result.toString()); reader.onloadend = () => resolve(reader.result?.toString());
reader.readAsDataURL(blob); reader.readAsDataURL(blob);
}); });