Enable @typescript-eslint/explicit-function-return-type
in /src (#9788)
* Enable `@typescript-eslint/explicit-member-accessibility` on /src * Prettier * Enable `@typescript-eslint/explicit-function-return-type` in /src * Fix types * tsc strict fixes * Delint * Fix test * Fix bad merge
This commit is contained in:
parent
7a36ba0fde
commit
030b7e90bf
683 changed files with 3459 additions and 3013 deletions
|
@ -39,13 +39,13 @@ export default class AudioFeed extends React.Component<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
MediaDeviceHandler.instance.addListener(MediaDeviceHandlerEvent.AudioOutputChanged, this.onAudioOutputChanged);
|
||||
this.props.feed.addListener(CallFeedEvent.NewStream, this.onNewStream);
|
||||
this.playMedia();
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
MediaDeviceHandler.instance.removeListener(
|
||||
MediaDeviceHandlerEvent.AudioOutputChanged,
|
||||
this.onAudioOutputChanged,
|
||||
|
@ -54,7 +54,7 @@ export default class AudioFeed extends React.Component<IProps, IState> {
|
|||
this.stopMedia();
|
||||
}
|
||||
|
||||
private onAudioOutputChanged = (audioOutput: string) => {
|
||||
private onAudioOutputChanged = (audioOutput: string): void => {
|
||||
const element = this.element.current;
|
||||
if (audioOutput) {
|
||||
try {
|
||||
|
@ -70,7 +70,7 @@ export default class AudioFeed extends React.Component<IProps, IState> {
|
|||
}
|
||||
};
|
||||
|
||||
private async playMedia() {
|
||||
private async playMedia(): Promise<void> {
|
||||
const element = this.element.current;
|
||||
if (!element) return;
|
||||
this.onAudioOutputChanged(MediaDeviceHandler.getAudioOutput());
|
||||
|
@ -98,7 +98,7 @@ export default class AudioFeed extends React.Component<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
private stopMedia() {
|
||||
private stopMedia(): void {
|
||||
const element = this.element.current;
|
||||
if (!element) return;
|
||||
|
||||
|
@ -111,14 +111,14 @@ export default class AudioFeed extends React.Component<IProps, IState> {
|
|||
// seem to be necessary - Šimon
|
||||
}
|
||||
|
||||
private onNewStream = () => {
|
||||
private onNewStream = (): void => {
|
||||
this.setState({
|
||||
audioMuted: this.props.feed.isAudioMuted(),
|
||||
});
|
||||
this.playMedia();
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
// Do not render the audio element if there is no audio track
|
||||
if (this.state.audioMuted) return null;
|
||||
|
||||
|
|
|
@ -37,21 +37,21 @@ export default class AudioFeedArrayForLegacyCall extends React.Component<IProps,
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
this.props.call.addListener(CallEvent.FeedsChanged, this.onFeedsChanged);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
this.props.call.removeListener(CallEvent.FeedsChanged, this.onFeedsChanged);
|
||||
}
|
||||
|
||||
public onFeedsChanged = () => {
|
||||
public onFeedsChanged = (): void => {
|
||||
this.setState({
|
||||
feeds: this.props.call.getRemoteFeeds(),
|
||||
});
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element[] {
|
||||
return this.state.feeds.map((feed, i) => {
|
||||
return <AudioFeed feed={feed} key={i} />;
|
||||
});
|
||||
|
|
|
@ -150,7 +150,7 @@ export const Lobby: FC<LobbyProps> = ({ room, joinCallButtonDisabledTooltip, con
|
|||
}, [videoMuted, setVideoMuted]);
|
||||
|
||||
const [videoStream, audioInputs, videoInputs] = useAsyncMemo(
|
||||
async () => {
|
||||
async (): Promise<[MediaStream, MediaDeviceInfo[], MediaDeviceInfo[]]> => {
|
||||
let devices = await MediaDeviceHandler.getDevices();
|
||||
|
||||
// We get the preview stream before requesting devices: this is because
|
||||
|
@ -210,7 +210,7 @@ export const Lobby: FC<LobbyProps> = ({ room, joinCallButtonDisabledTooltip, con
|
|||
}, [videoStream]);
|
||||
|
||||
const onConnectClick = useCallback(
|
||||
async (ev: ButtonEvent) => {
|
||||
async (ev: ButtonEvent): Promise<void> => {
|
||||
ev.preventDefault();
|
||||
setConnecting(true);
|
||||
try {
|
||||
|
@ -298,7 +298,7 @@ const StartCallView: FC<StartCallViewProps> = ({ room, resizing, call, setStarti
|
|||
const [connected, setConnected] = useState(() => call !== null && isConnected(call.connectionState));
|
||||
useEffect(() => {
|
||||
if (call !== null) {
|
||||
const onConnectionState = (state: ConnectionState) => setConnected(isConnected(state));
|
||||
const onConnectionState = (state: ConnectionState): void => setConnected(isConnected(state));
|
||||
call.on(CallEvent.ConnectionState, onConnectionState);
|
||||
return () => {
|
||||
call.off(CallEvent.ConnectionState, onConnectionState);
|
||||
|
@ -306,14 +306,14 @@ const StartCallView: FC<StartCallViewProps> = ({ room, resizing, call, setStarti
|
|||
}
|
||||
}, [call]);
|
||||
|
||||
const connect = useCallback(async () => {
|
||||
const connect = useCallback(async (): Promise<void> => {
|
||||
setStartingCall(true);
|
||||
await ElementCall.create(room);
|
||||
await connectDeferred.promise;
|
||||
}, [room, setStartingCall, connectDeferred]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
(async (): Promise<void> => {
|
||||
// If the call was successfully started, connect automatically
|
||||
if (call !== null) {
|
||||
try {
|
||||
|
@ -358,7 +358,7 @@ const JoinCallView: FC<JoinCallViewProps> = ({ room, resizing, call }) => {
|
|||
const members = useParticipatingMembers(call);
|
||||
const joinCallButtonDisabledTooltip = useJoinCallButtonDisabledTooltip(call);
|
||||
|
||||
const connect = useCallback(async () => {
|
||||
const connect = useCallback(async (): Promise<void> => {
|
||||
// Disconnect from any other active calls first, since we don't yet support holding
|
||||
await Promise.all([...CallStore.instance.activeCalls].map((call) => call.disconnect()));
|
||||
await call.connect();
|
||||
|
|
|
@ -35,11 +35,11 @@ interface IButtonProps {
|
|||
}
|
||||
|
||||
class DialPadButton extends React.PureComponent<IButtonProps> {
|
||||
public onClick = (ev: ButtonEvent) => {
|
||||
public onClick = (ev: ButtonEvent): void => {
|
||||
this.props.onButtonPress(this.props.digit, ev);
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
switch (this.props.kind) {
|
||||
case DialPadButtonKind.Digit:
|
||||
return (
|
||||
|
@ -68,7 +68,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
export default class Dialpad extends React.PureComponent<IProps> {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const buttonNodes = [];
|
||||
|
||||
for (let i = 0; i < BUTTONS.length; i++) {
|
||||
|
|
|
@ -41,20 +41,20 @@ export default class DialpadModal extends React.PureComponent<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
public onCancelClick = () => {
|
||||
public onCancelClick = (): void => {
|
||||
this.props.onFinished(false);
|
||||
};
|
||||
|
||||
public onChange = (ev) => {
|
||||
public onChange = (ev): void => {
|
||||
this.setState({ value: ev.target.value });
|
||||
};
|
||||
|
||||
public onFormSubmit = (ev) => {
|
||||
public onFormSubmit = (ev): void => {
|
||||
ev.preventDefault();
|
||||
this.onDialPress();
|
||||
};
|
||||
|
||||
public onDigitPress = (digit: string, ev: ButtonEvent) => {
|
||||
public onDigitPress = (digit: string, ev: ButtonEvent): void => {
|
||||
this.setState({ value: this.state.value + digit });
|
||||
|
||||
// Keep the number field focused so that keyboard entry is still available.
|
||||
|
@ -65,7 +65,7 @@ export default class DialpadModal extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
};
|
||||
|
||||
public onDeletePress = (ev: ButtonEvent) => {
|
||||
public onDeletePress = (ev: ButtonEvent): void => {
|
||||
if (this.state.value.length === 0) return;
|
||||
this.setState({ value: this.state.value.slice(0, -1) });
|
||||
|
||||
|
@ -77,12 +77,12 @@ export default class DialpadModal extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
};
|
||||
|
||||
public onDialPress = async () => {
|
||||
public onDialPress = async (): Promise<void> => {
|
||||
LegacyCallHandler.instance.dialNumber(this.state.value);
|
||||
this.props.onFinished(true);
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const backspaceButton = <DialPadBackspaceButton onBackspacePress={this.onDeletePress} />;
|
||||
|
||||
// Only show the backspace button if the field has content
|
||||
|
|
|
@ -76,7 +76,7 @@ interface IState {
|
|||
sidebarShown: boolean;
|
||||
}
|
||||
|
||||
function getFullScreenElement() {
|
||||
function getFullScreenElement(): Element | undefined {
|
||||
return (
|
||||
document.fullscreenElement ||
|
||||
// moz omitted because firefox supports this unprefixed now (webkit here for safari)
|
||||
|
@ -85,7 +85,7 @@ function getFullScreenElement() {
|
|||
);
|
||||
}
|
||||
|
||||
function requestFullscreen(element: Element) {
|
||||
function requestFullscreen(element: Element): void {
|
||||
const method =
|
||||
element.requestFullscreen ||
|
||||
// moz omitted since firefox supports unprefixed now
|
||||
|
@ -94,7 +94,7 @@ function requestFullscreen(element: Element) {
|
|||
if (method) method.call(element);
|
||||
}
|
||||
|
||||
function exitFullscreen() {
|
||||
function exitFullscreen(): void {
|
||||
const exitMethod = document.exitFullscreen || document.webkitExitFullscreen || document.msExitFullscreen;
|
||||
if (exitMethod) exitMethod.call(document);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import LegacyCallContextMenu from "../../context_menus/LegacyCallContextMenu";
|
|||
import DialpadContextMenu from "../../context_menus/DialpadContextMenu";
|
||||
import { Alignment } from "../../elements/Tooltip";
|
||||
import {
|
||||
alwaysAboveLeftOf,
|
||||
alwaysMenuProps,
|
||||
alwaysAboveRightOf,
|
||||
ChevronFace,
|
||||
ContextMenuTooltipButton,
|
||||
|
@ -226,7 +226,7 @@ export default class LegacyCallViewButtons extends React.Component<IProps, IStat
|
|||
if (this.state.showDialpad) {
|
||||
dialPad = (
|
||||
<DialpadContextMenu
|
||||
{...alwaysAboveLeftOf(
|
||||
{...alwaysMenuProps(
|
||||
this.dialpadButton.current.getBoundingClientRect(),
|
||||
ChevronFace.None,
|
||||
CONTEXT_MENU_VPADDING,
|
||||
|
@ -246,7 +246,7 @@ export default class LegacyCallViewButtons extends React.Component<IProps, IStat
|
|||
if (this.state.showMoreMenu) {
|
||||
contextMenu = (
|
||||
<LegacyCallContextMenu
|
||||
{...alwaysAboveLeftOf(
|
||||
{...alwaysMenuProps(
|
||||
this.contextMenuButton.current.getBoundingClientRect(),
|
||||
ChevronFace.None,
|
||||
CONTEXT_MENU_VPADDING,
|
||||
|
|
|
@ -47,17 +47,17 @@ export default class LegacyCallViewForRoom extends React.Component<IProps, IStat
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
LegacyCallHandler.instance.addListener(LegacyCallHandlerEvent.CallState, this.updateCall);
|
||||
LegacyCallHandler.instance.addListener(LegacyCallHandlerEvent.CallChangeRoom, this.updateCall);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
LegacyCallHandler.instance.removeListener(LegacyCallHandlerEvent.CallState, this.updateCall);
|
||||
LegacyCallHandler.instance.removeListener(LegacyCallHandlerEvent.CallChangeRoom, this.updateCall);
|
||||
}
|
||||
|
||||
private updateCall = () => {
|
||||
private updateCall = (): void => {
|
||||
const newCall = this.getCall();
|
||||
if (newCall !== this.state.call) {
|
||||
this.setState({ call: newCall });
|
||||
|
@ -71,19 +71,19 @@ export default class LegacyCallViewForRoom extends React.Component<IProps, IStat
|
|||
return call;
|
||||
}
|
||||
|
||||
private onResizeStart = () => {
|
||||
private onResizeStart = (): void => {
|
||||
this.props.resizeNotifier.startResizing();
|
||||
};
|
||||
|
||||
private onResize = () => {
|
||||
private onResize = (): void => {
|
||||
this.props.resizeNotifier.notifyTimelineHeightChanged();
|
||||
};
|
||||
|
||||
private onResizeStop = () => {
|
||||
private onResizeStop = (): void => {
|
||||
this.props.resizeNotifier.stopResizing();
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
if (!this.state.call) return null;
|
||||
|
||||
return (
|
||||
|
|
|
@ -28,7 +28,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
export default class LegacyCallViewSidebar extends React.Component<IProps> {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const feeds = this.props.feeds.map((feed) => {
|
||||
return (
|
||||
<VideoFeed
|
||||
|
|
|
@ -61,16 +61,16 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
this.updateFeed(null, this.props.feed);
|
||||
this.playMedia();
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
this.updateFeed(this.props.feed, null);
|
||||
}
|
||||
|
||||
public componentDidUpdate(prevProps: IProps, prevState: IState) {
|
||||
public componentDidUpdate(prevProps: IProps, prevState: IState): void {
|
||||
this.updateFeed(prevProps.feed, this.props.feed);
|
||||
// If the mutes state has changed, we try to playMedia()
|
||||
if (prevState.videoMuted !== this.state.videoMuted || prevProps.feed.stream !== this.props.feed.stream) {
|
||||
|
@ -78,7 +78,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
public static getDerivedStateFromProps(props: IProps) {
|
||||
public static getDerivedStateFromProps(props: IProps): IState {
|
||||
return {
|
||||
audioMuted: props.feed.isAudioMuted(),
|
||||
videoMuted: props.feed.isVideoMuted(),
|
||||
|
@ -95,7 +95,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
element.addEventListener("resize", this.onResize);
|
||||
};
|
||||
|
||||
private updateFeed(oldFeed: CallFeed, newFeed: CallFeed) {
|
||||
private updateFeed(oldFeed: CallFeed, newFeed: CallFeed): void {
|
||||
if (oldFeed === newFeed) return;
|
||||
|
||||
if (oldFeed) {
|
||||
|
@ -116,7 +116,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
private async playMedia() {
|
||||
private async playMedia(): Promise<void> {
|
||||
const element = this.element;
|
||||
if (!element) return;
|
||||
// We play audio in AudioFeed, not here
|
||||
|
@ -143,7 +143,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
private stopMedia() {
|
||||
private stopMedia(): void {
|
||||
const element = this.element;
|
||||
if (!element) return;
|
||||
|
||||
|
@ -156,7 +156,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
// seem to be necessary - Šimon
|
||||
}
|
||||
|
||||
private onNewStream = () => {
|
||||
private onNewStream = (): void => {
|
||||
this.setState({
|
||||
audioMuted: this.props.feed.isAudioMuted(),
|
||||
videoMuted: this.props.feed.isVideoMuted(),
|
||||
|
@ -164,20 +164,20 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
|||
this.playMedia();
|
||||
};
|
||||
|
||||
private onMuteStateChanged = () => {
|
||||
private onMuteStateChanged = (): void => {
|
||||
this.setState({
|
||||
audioMuted: this.props.feed.isAudioMuted(),
|
||||
videoMuted: this.props.feed.isVideoMuted(),
|
||||
});
|
||||
};
|
||||
|
||||
private onResize = (e) => {
|
||||
private onResize = (e): void => {
|
||||
if (this.props.onResize && !this.props.feed.isLocal()) {
|
||||
this.props.onResize(e);
|
||||
}
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { pipMode, primary, secondary, feed } = this.props;
|
||||
|
||||
const wrapperClasses = classnames("mx_VideoFeed", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue