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
|
@ -35,7 +35,7 @@ export const VoiceBroadcastBody: React.FC<IBodyProps> = ({ mxEvent }) => {
|
|||
const [infoState, setInfoState] = useState(mxEvent.getContent()?.state || VoiceBroadcastInfoState.Stopped);
|
||||
|
||||
useEffect(() => {
|
||||
const onInfoEvent = (event: MatrixEvent) => {
|
||||
const onInfoEvent = (event: MatrixEvent): void => {
|
||||
if (event.getContent()?.state === VoiceBroadcastInfoState.Stopped) {
|
||||
// only a stopped event can change the tile state
|
||||
setInfoState(VoiceBroadcastInfoState.Stopped);
|
||||
|
|
|
@ -50,7 +50,7 @@ export const VoiceBroadcastHeader: React.FC<VoiceBroadcastHeaderProps> = ({
|
|||
linkToRoom = false,
|
||||
live = "not-live",
|
||||
liveBadgePosition = "right",
|
||||
onCloseClick = () => {},
|
||||
onCloseClick = (): void => {},
|
||||
onMicrophoneLineClick = null,
|
||||
room,
|
||||
microphoneLabel,
|
||||
|
|
|
@ -19,7 +19,7 @@ import React from "react";
|
|||
import { Icon as LiveIcon } from "../../../../res/img/element-icons/live.svg";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
export const VoiceBroadcastRoomSubtitle = () => {
|
||||
export const VoiceBroadcastRoomSubtitle: React.FC = () => {
|
||||
return (
|
||||
<div className="mx_RoomTile_subtitle mx_RoomTile_subtitle--voice-broadcast">
|
||||
<LiveIcon className="mx_Icon mx_Icon_16" />
|
||||
|
|
|
@ -45,7 +45,7 @@ export const VoiceBroadcastPlaybackBody: React.FC<VoiceBroadcastPlaybackBodyProp
|
|||
let seekForwardButton: ReactElement | null = null;
|
||||
|
||||
if (playbackState !== VoiceBroadcastPlaybackState.Stopped) {
|
||||
const onSeekBackwardButtonClick = () => {
|
||||
const onSeekBackwardButtonClick = (): void => {
|
||||
playback.skipTo(Math.max(0, times.position - SEEK_TIME));
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@ export const VoiceBroadcastPlaybackBody: React.FC<VoiceBroadcastPlaybackBodyProp
|
|||
<SeekButton icon={Back30sIcon} label={_t("30s backward")} onClick={onSeekBackwardButtonClick} />
|
||||
);
|
||||
|
||||
const onSeekForwardButtonClick = () => {
|
||||
const onSeekForwardButtonClick = (): void => {
|
||||
playback.skipTo(Math.min(times.duration, times.position + SEEK_TIME));
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ export const VoiceBroadcastPreRecordingPip: React.FC<Props> = ({ voiceBroadcastP
|
|||
disableStartButton: false,
|
||||
});
|
||||
|
||||
const onDeviceSelect = (device: MediaDeviceInfo) => {
|
||||
const onDeviceSelect = (device: MediaDeviceInfo): void => {
|
||||
setState((state) => ({
|
||||
...state,
|
||||
showDeviceSelect: false,
|
||||
|
@ -49,7 +49,7 @@ export const VoiceBroadcastPreRecordingPip: React.FC<Props> = ({ voiceBroadcastP
|
|||
setDevice(device);
|
||||
};
|
||||
|
||||
const onStartBroadcastClick = () => {
|
||||
const onStartBroadcastClick = (): void => {
|
||||
setState((state) => ({
|
||||
...state,
|
||||
disableStartButton: true,
|
||||
|
@ -63,7 +63,7 @@ export const VoiceBroadcastPreRecordingPip: React.FC<Props> = ({ voiceBroadcastP
|
|||
<VoiceBroadcastHeader
|
||||
linkToRoom={true}
|
||||
onCloseClick={voiceBroadcastPreRecording.cancel}
|
||||
onMicrophoneLineClick={() => setState({ ...state, showDeviceSelect: true })}
|
||||
onMicrophoneLineClick={(): void => setState({ ...state, showDeviceSelect: true })}
|
||||
room={voiceBroadcastPreRecording.room}
|
||||
microphoneLabel={currentDeviceLabel}
|
||||
showClose={true}
|
||||
|
|
|
@ -38,7 +38,7 @@ export const VoiceBroadcastRecordingPip: React.FC<VoiceBroadcastRecordingPipProp
|
|||
useVoiceBroadcastRecording(recording);
|
||||
const { currentDevice, devices, setDevice } = useAudioDeviceSelection();
|
||||
|
||||
const onDeviceSelect = async (device: MediaDeviceInfo) => {
|
||||
const onDeviceSelect = async (device: MediaDeviceInfo): Promise<void> => {
|
||||
setShowDeviceSelect(false);
|
||||
|
||||
if (currentDevice.deviceId === device.deviceId) {
|
||||
|
@ -78,7 +78,10 @@ export const VoiceBroadcastRecordingPip: React.FC<VoiceBroadcastRecordingPipProp
|
|||
<hr className="mx_VoiceBroadcastBody_divider" />
|
||||
<div className="mx_VoiceBroadcastBody_controls">
|
||||
{toggleControl}
|
||||
<AccessibleTooltipButton onClick={() => setShowDeviceSelect(true)} title={_t("Change input device")}>
|
||||
<AccessibleTooltipButton
|
||||
onClick={(): void => setShowDeviceSelect(true)}
|
||||
title={_t("Change input device")}
|
||||
>
|
||||
<MicrophoneIcon className="mx_Icon mx_Icon_16 mx_Icon_alert" />
|
||||
</AccessibleTooltipButton>
|
||||
<VoiceBroadcastControl icon={StopIcon} label="Stop Recording" onClick={stopRecording} />
|
||||
|
|
|
@ -23,7 +23,11 @@ import {
|
|||
VoiceBroadcastPlaybacksStoreEvent,
|
||||
} from "../stores/VoiceBroadcastPlaybacksStore";
|
||||
|
||||
export const useCurrentVoiceBroadcastPlayback = (voiceBroadcastPlaybackStore: VoiceBroadcastPlaybacksStore) => {
|
||||
export const useCurrentVoiceBroadcastPlayback = (
|
||||
voiceBroadcastPlaybackStore: VoiceBroadcastPlaybacksStore,
|
||||
): {
|
||||
currentVoiceBroadcastPlayback: VoiceBroadcastPlayback | null;
|
||||
} => {
|
||||
const [currentVoiceBroadcastPlayback, setVoiceBroadcastPlayback] = useState(
|
||||
voiceBroadcastPlaybackStore.getCurrent(),
|
||||
);
|
||||
|
|
|
@ -18,10 +18,13 @@ import { useState } from "react";
|
|||
|
||||
import { useTypedEventEmitter } from "../../hooks/useEventEmitter";
|
||||
import { VoiceBroadcastPreRecordingStore } from "../stores/VoiceBroadcastPreRecordingStore";
|
||||
import { VoiceBroadcastPreRecording } from "../models/VoiceBroadcastPreRecording";
|
||||
|
||||
export const useCurrentVoiceBroadcastPreRecording = (
|
||||
voiceBroadcastPreRecordingStore: VoiceBroadcastPreRecordingStore,
|
||||
) => {
|
||||
): {
|
||||
currentVoiceBroadcastPreRecording: VoiceBroadcastPreRecording | null;
|
||||
} => {
|
||||
const [currentVoiceBroadcastPreRecording, setCurrentVoiceBroadcastPreRecording] = useState(
|
||||
voiceBroadcastPreRecordingStore.getCurrent(),
|
||||
);
|
||||
|
|
|
@ -16,10 +16,14 @@ limitations under the License.
|
|||
|
||||
import { useState } from "react";
|
||||
|
||||
import { VoiceBroadcastRecordingsStore, VoiceBroadcastRecordingsStoreEvent } from "..";
|
||||
import { VoiceBroadcastRecording, VoiceBroadcastRecordingsStore, VoiceBroadcastRecordingsStoreEvent } from "..";
|
||||
import { useTypedEventEmitter } from "../../hooks/useEventEmitter";
|
||||
|
||||
export const useCurrentVoiceBroadcastRecording = (voiceBroadcastRecordingsStore: VoiceBroadcastRecordingsStore) => {
|
||||
export const useCurrentVoiceBroadcastRecording = (
|
||||
voiceBroadcastRecordingsStore: VoiceBroadcastRecordingsStore,
|
||||
): {
|
||||
currentVoiceBroadcastRecording: VoiceBroadcastRecording;
|
||||
} => {
|
||||
const [currentVoiceBroadcastRecording, setCurrentVoiceBroadcastRecording] = useState(
|
||||
voiceBroadcastRecordingsStore.getCurrent(),
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@ import { hasRoomLiveVoiceBroadcast } from "../utils/hasRoomLiveVoiceBroadcast";
|
|||
import { useTypedEventEmitter } from "../../hooks/useEventEmitter";
|
||||
import { SDKContext } from "../../contexts/SDKContext";
|
||||
|
||||
export const useHasRoomLiveVoiceBroadcast = (room: Room) => {
|
||||
export const useHasRoomLiveVoiceBroadcast = (room: Room): boolean => {
|
||||
const sdkContext = useContext(SDKContext);
|
||||
const [hasLiveVoiceBroadcast, setHasLiveVoiceBroadcast] = useState(false);
|
||||
|
||||
|
|
|
@ -15,12 +15,32 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
|
||||
import { useTypedEventEmitter } from "../../hooks/useEventEmitter";
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { VoiceBroadcastPlayback, VoiceBroadcastPlaybackEvent, VoiceBroadcastPlaybackState } from "..";
|
||||
import {
|
||||
VoiceBroadcastLiveness,
|
||||
VoiceBroadcastPlayback,
|
||||
VoiceBroadcastPlaybackEvent,
|
||||
VoiceBroadcastPlaybackState,
|
||||
} from "..";
|
||||
|
||||
export const useVoiceBroadcastPlayback = (playback: VoiceBroadcastPlayback) => {
|
||||
export const useVoiceBroadcastPlayback = (
|
||||
playback: VoiceBroadcastPlayback,
|
||||
): {
|
||||
times: {
|
||||
duration: number;
|
||||
position: number;
|
||||
timeLeft: number;
|
||||
};
|
||||
sender: RoomMember;
|
||||
liveness: VoiceBroadcastLiveness;
|
||||
playbackState: VoiceBroadcastPlaybackState;
|
||||
toggle(): void;
|
||||
room: Room;
|
||||
} => {
|
||||
const client = MatrixClientPeg.get();
|
||||
const room = client.getRoom(playback.infoEvent.getRoomId());
|
||||
|
||||
|
@ -28,7 +48,7 @@ export const useVoiceBroadcastPlayback = (playback: VoiceBroadcastPlayback) => {
|
|||
throw new Error(`Voice Broadcast room not found (event ${playback.infoEvent.getId()})`);
|
||||
}
|
||||
|
||||
const playbackToggle = () => {
|
||||
const playbackToggle = (): void => {
|
||||
playback.toggle();
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { VoiceBroadcastInfoState, VoiceBroadcastRecording, VoiceBroadcastRecordingEvent } from "..";
|
||||
|
@ -40,7 +42,17 @@ const showStopBroadcastingDialog = async (): Promise<boolean> => {
|
|||
return confirmed;
|
||||
};
|
||||
|
||||
export const useVoiceBroadcastRecording = (recording: VoiceBroadcastRecording) => {
|
||||
export const useVoiceBroadcastRecording = (
|
||||
recording: VoiceBroadcastRecording,
|
||||
): {
|
||||
live: boolean;
|
||||
timeLeft: number;
|
||||
recordingState: VoiceBroadcastInfoState;
|
||||
room: Room;
|
||||
sender: RoomMember;
|
||||
stopRecording(): void;
|
||||
toggleRecording(): void;
|
||||
} => {
|
||||
const client = MatrixClientPeg.get();
|
||||
const roomId = recording.infoEvent.getRoomId();
|
||||
const room = client.getRoom(roomId);
|
||||
|
@ -49,7 +61,7 @@ export const useVoiceBroadcastRecording = (recording: VoiceBroadcastRecording) =
|
|||
throw new Error("Unable to find voice broadcast room with Id: " + roomId);
|
||||
}
|
||||
|
||||
const stopRecording = async () => {
|
||||
const stopRecording = async (): Promise<void> => {
|
||||
const confirmed = await showStopBroadcastingDialog();
|
||||
|
||||
if (confirmed) {
|
||||
|
|
|
@ -193,7 +193,7 @@ export class VoiceBroadcastPlayback
|
|||
this.setInfoState(state);
|
||||
};
|
||||
|
||||
private onBeforeRedaction = () => {
|
||||
private onBeforeRedaction = (): void => {
|
||||
if (this.getState() !== VoiceBroadcastPlaybackState.Stopped) {
|
||||
this.stop();
|
||||
// destroy cleans up everything
|
||||
|
@ -466,7 +466,7 @@ export class VoiceBroadcastPlayback
|
|||
* playing → paused
|
||||
* paused → playing
|
||||
*/
|
||||
public async toggle() {
|
||||
public async toggle(): Promise<void> {
|
||||
if (this.state === VoiceBroadcastPlaybackState.Stopped) {
|
||||
await this.start();
|
||||
return;
|
||||
|
|
|
@ -223,7 +223,7 @@ export class VoiceBroadcastRecording
|
|||
this.chunkRelationHelper.destroy();
|
||||
}
|
||||
|
||||
private onBeforeRedaction = () => {
|
||||
private onBeforeRedaction = (): void => {
|
||||
if (this.getState() !== VoiceBroadcastInfoState.Stopped) {
|
||||
this.setState(VoiceBroadcastInfoState.Stopped);
|
||||
// destroy cleans up everything
|
||||
|
@ -231,7 +231,7 @@ export class VoiceBroadcastRecording
|
|||
}
|
||||
};
|
||||
|
||||
private onAction = (payload: ActionPayload) => {
|
||||
private onAction = (payload: ActionPayload): void => {
|
||||
if (payload.action !== "call_state") return;
|
||||
|
||||
// pause on any call action
|
||||
|
@ -243,7 +243,7 @@ export class VoiceBroadcastRecording
|
|||
this.emit(VoiceBroadcastRecordingEvent.StateChanged, this.state);
|
||||
}
|
||||
|
||||
private onCurrentChunkLengthUpdated = (currentChunkLength: number) => {
|
||||
private onCurrentChunkLengthUpdated = (currentChunkLength: number): void => {
|
||||
this.setTimeLeft(this.maxLength - this.chunkEvents.getLengthSeconds() - currentChunkLength);
|
||||
};
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ export class VoiceBroadcastRecordingsStore extends TypedEventEmitter<VoiceBroadc
|
|||
return recording;
|
||||
}
|
||||
|
||||
private onCurrentStateChanged = (state: VoiceBroadcastInfoState) => {
|
||||
private onCurrentStateChanged = (state: VoiceBroadcastInfoState): void => {
|
||||
if (state === VoiceBroadcastInfoState.Stopped) {
|
||||
this.clearCurrent();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ export class VoiceBroadcastResumer implements IDestroyable {
|
|||
}
|
||||
}
|
||||
|
||||
private onClientSync = () => {
|
||||
private onClientSync = (): void => {
|
||||
if (this.client.getSyncState() === SyncState.Syncing) {
|
||||
this.client.off(ClientEvent.Sync, this.onClientSync);
|
||||
this.resume();
|
||||
|
|
|
@ -23,7 +23,7 @@ import InfoDialog from "../../components/views/dialogs/InfoDialog";
|
|||
import { _t } from "../../languageHandler";
|
||||
import Modal from "../../Modal";
|
||||
|
||||
const showAlreadyRecordingDialog = () => {
|
||||
const showAlreadyRecordingDialog = (): void => {
|
||||
Modal.createDialog(InfoDialog, {
|
||||
title: _t("Can't start a new voice broadcast"),
|
||||
description: (
|
||||
|
@ -38,7 +38,7 @@ const showAlreadyRecordingDialog = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const showInsufficientPermissionsDialog = () => {
|
||||
const showInsufficientPermissionsDialog = (): void => {
|
||||
Modal.createDialog(InfoDialog, {
|
||||
title: _t("Can't start a new voice broadcast"),
|
||||
description: (
|
||||
|
@ -53,7 +53,7 @@ const showInsufficientPermissionsDialog = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const showOthersAlreadyRecordingDialog = () => {
|
||||
const showOthersAlreadyRecordingDialog = (): void => {
|
||||
Modal.createDialog(InfoDialog, {
|
||||
title: _t("Can't start a new voice broadcast"),
|
||||
description: (
|
||||
|
|
|
@ -18,7 +18,7 @@ import { VoiceBroadcastPlaybacksStore, VoiceBroadcastPlaybackState } from "..";
|
|||
|
||||
export const doClearCurrentVoiceBroadcastPlaybackIfStopped = (
|
||||
voiceBroadcastPlaybacksStore: VoiceBroadcastPlaybacksStore,
|
||||
) => {
|
||||
): void => {
|
||||
if (voiceBroadcastPlaybacksStore.getCurrent()?.getState() === VoiceBroadcastPlaybackState.Stopped) {
|
||||
// clear current if stopped
|
||||
return;
|
||||
|
|
|
@ -18,6 +18,6 @@ import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
|||
|
||||
import { VoiceBroadcastInfoEventType, VoiceBroadcastInfoState } from "..";
|
||||
|
||||
export const shouldDisplayAsVoiceBroadcastTile = (event: MatrixEvent) =>
|
||||
export const shouldDisplayAsVoiceBroadcastTile = (event: MatrixEvent): boolean =>
|
||||
event.getType?.() === VoiceBroadcastInfoEventType &&
|
||||
(event.getContent?.()?.state === VoiceBroadcastInfoState.Started || event.isRedacted());
|
||||
|
|
|
@ -20,7 +20,7 @@ import InfoDialog from "../../components/views/dialogs/InfoDialog";
|
|||
import { _t } from "../../languageHandler";
|
||||
import Modal from "../../Modal";
|
||||
|
||||
export const showCantStartACallDialog = () => {
|
||||
export const showCantStartACallDialog = (): void => {
|
||||
Modal.createDialog(InfoDialog, {
|
||||
title: _t("Can’t start a call"),
|
||||
description: (
|
||||
|
|
|
@ -44,7 +44,7 @@ const startBroadcast = async (
|
|||
|
||||
let result: ISendEventResponse | null = null;
|
||||
|
||||
const onRoomStateEvents = () => {
|
||||
const onRoomStateEvents = (): void => {
|
||||
if (!result) return;
|
||||
|
||||
const voiceBroadcastEvent = room.currentState.getStateEvents(VoiceBroadcastInfoEventType, userId);
|
||||
|
|
|
@ -32,7 +32,7 @@ export const textForVoiceBroadcastStoppedEvent = (event: MatrixEvent): (() => Re
|
|||
const templateTags = {
|
||||
a: (text: string) =>
|
||||
startEventId && roomId ? (
|
||||
<AccessibleButton kind="link_inline" onClick={() => highlightEvent(roomId, startEventId)}>
|
||||
<AccessibleButton kind="link_inline" onClick={(): void => highlightEvent(roomId, startEventId)}>
|
||||
{text}
|
||||
</AccessibleButton>
|
||||
) : (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue