ref(TS) Convert some features to TS (#12366)

This commit is contained in:
Robert Pintilii 2022-10-13 11:26:28 +03:00 committed by GitHub
parent 70503d2518
commit f5fb402784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 107 additions and 105 deletions

View File

@ -1,11 +1,12 @@
import { createDeviceChangedEvent, sendAnalytics } from '../analytics'; import { createDeviceChangedEvent } from '../analytics/AnalyticsEvents';
import { sendAnalytics } from '../analytics/functions';
import { IStore } from '../app/types';
import { import {
getDeviceLabelById,
setAudioInputDevice, setAudioInputDevice,
setAudioOutputDeviceId,
setVideoInputDevice setVideoInputDevice
} from '../base/devices'; } from '../base/devices/actions';
import { updateSettings } from '../base/settings'; import { getDeviceLabelById, setAudioOutputDeviceId } from '../base/devices/functions';
import { updateSettings } from '../base/settings/actions';
import { getDeviceSelectionDialogProps } from './functions'; import { getDeviceSelectionDialogProps } from './functions';
import logger from './logger'; import logger from './logger';
@ -18,8 +19,8 @@ import logger from './logger';
* welcome page or not. * welcome page or not.
* @returns {Function} * @returns {Function}
*/ */
export function submitDeviceSelectionTab(newState, isDisplayedOnWelcomePage) { export function submitDeviceSelectionTab(newState: any, isDisplayedOnWelcomePage: boolean) {
return (dispatch, getState) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const currentState = getDeviceSelectionDialogProps(getState(), isDisplayedOnWelcomePage); const currentState = getDeviceSelectionDialogProps(getState(), isDisplayedOnWelcomePage);
if (newState.selectedVideoInputId && (newState.selectedVideoInputId !== currentState.selectedVideoInputId)) { if (newState.selectedVideoInputId && (newState.selectedVideoInputId !== currentState.selectedVideoInputId)) {

View File

@ -1,5 +1,3 @@
// @flow
import { getLogger } from '../base/logging/functions'; import { getLogger } from '../base/logging/functions';
export default getLogger('features/device-selection'); export default getLogger('features/device-selection');

View File

@ -1,9 +1,5 @@
// @flow import { UPDATE_DEVICE_LIST } from '../base/devices/actionTypes';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { UPDATE_DEVICE_LIST } from '../base/devices';
import { MiddlewareRegistry } from '../base/redux';
declare var APP: Object;
/** /**
* Implements the middleware of the feature device-selection. * Implements the middleware of the feature device-selection.

View File

@ -1,4 +1,4 @@
import { doGetJSON } from '../base/util'; import { doGetJSON } from '../base/util/httpUtils';
import { import {
SET_DYNAMIC_BRANDING_DATA, SET_DYNAMIC_BRANDING_DATA,
@ -47,7 +47,7 @@ export function fetchCustomBrandingData() {
* @param {Object} value - The custom data to be set. * @param {Object} value - The custom data to be set.
* @returns {Object} * @returns {Object}
*/ */
export function setDynamicBrandingData(value) { export function setDynamicBrandingData(value: Object) {
return { return {
type: SET_DYNAMIC_BRANDING_DATA, type: SET_DYNAMIC_BRANDING_DATA,
value value

View File

@ -1,4 +1,5 @@
import { doGetJSON } from '../base/util'; import { IStore } from '../app/types';
import { doGetJSON } from '../base/util/httpUtils';
import { UNSET_DYNAMIC_BRANDING } from './actionTypes'; import { UNSET_DYNAMIC_BRANDING } from './actionTypes';
import { import {
@ -18,7 +19,7 @@ import logger from './logger';
* @returns {Function} * @returns {Function}
*/ */
export function fetchCustomBrandingData() { export function fetchCustomBrandingData() {
return async function(dispatch: Function, getState: Function) { return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
const state = getState(); const state = getState();
const dynamicBrandingUrl = await getDynamicBrandingUrl(state); const dynamicBrandingUrl = await getDynamicBrandingUrl(state);

View File

@ -1,5 +1,3 @@
// @flow
import { getLogger } from '../base/logging/functions'; import { getLogger } from '../base/logging/functions';
export default getLogger('features/dynamic-branding'); export default getLogger('features/dynamic-branding');

View File

@ -1,5 +1,5 @@
import { SET_CONFIG } from '../base/config'; import { SET_CONFIG } from '../base/config/actionTypes';
import { MiddlewareRegistry } from '../base/redux'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes'; import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes';
import { fetchCustomBrandingData } from './actions.native'; import { fetchCustomBrandingData } from './actions.native';
@ -34,7 +34,7 @@ MiddlewareRegistry.register(store => next => action => {
// TODO: implement support for gradients. // TODO: implement support for gradients.
action.value.avatarBackgrounds = avatarBackgrounds.filter( action.value.avatarBackgrounds = avatarBackgrounds.filter(
color => !color.includes('linear-gradient') (color: string) => !color.includes('linear-gradient')
); );
break; break;

View File

@ -1,5 +1,5 @@
import { APP_WILL_MOUNT } from '../base/app'; import { APP_WILL_MOUNT } from '../base/app/actionTypes';
import { MiddlewareRegistry } from '../base/redux'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes'; import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes';
import { fetchCustomBrandingData } from './actions.any'; import { fetchCustomBrandingData } from './actions.any';

View File

@ -1,5 +1,3 @@
// @flow
import { import {
SET_DOCUMENT_EDITING_STATUS, SET_DOCUMENT_EDITING_STATUS,
SET_DOCUMENT_URL, SET_DOCUMENT_URL,
@ -32,7 +30,7 @@ export function setDocumentEditingState(editing: boolean) {
* documentUrl: string * documentUrl: string
* }} * }}
*/ */
export function setDocumentUrl(documentUrl: ?string) { export function setDocumentUrl(documentUrl?: string) {
return { return {
type: SET_DOCUMENT_URL, type: SET_DOCUMENT_URL,
documentUrl documentUrl

View File

@ -1,6 +1,5 @@
// @flow import { IStateful } from '../base/app/types';
import { toState } from '../base/redux/functions';
import { toState } from '../base/redux';
const ETHERPAD_OPTIONS = { const ETHERPAD_OPTIONS = {
showControls: 'true', showControls: 'true',
@ -15,7 +14,7 @@ const ETHERPAD_OPTIONS = {
* @param {Function|Object} stateful - The redux store or {@code getState} function. * @param {Function|Object} stateful - The redux store or {@code getState} function.
* @returns {?string} - Current shared document URL or undefined. * @returns {?string} - Current shared document URL or undefined.
*/ */
export function getSharedDocumentUrl(stateful: Function | Object) { export function getSharedDocumentUrl(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { documentUrl } = state['features/etherpad']; const { documentUrl } = state['features/etherpad'];
const { displayName } = state['features/base/settings']; const { displayName } = state['features/base/settings'];

View File

@ -1,15 +1,13 @@
// @flow // @ts-expect-error
import UIEvents from '../../../service/UI/UIEvents'; import UIEvents from '../../../service/UI/UIEvents';
import { getCurrentConference } from '../base/conference';
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes'; import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux'; import { getCurrentConference } from '../base/conference/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { TOGGLE_DOCUMENT_EDITING } from './actionTypes'; import { TOGGLE_DOCUMENT_EDITING } from './actionTypes';
import { setDocumentUrl } from './actions'; import { setDocumentUrl } from './actions';
declare var APP: Object;
const ETHERPAD_COMMAND = 'etherpad'; const ETHERPAD_COMMAND = 'etherpad';
/** /**
@ -26,7 +24,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const { conference } = action; const { conference } = action;
conference.addCommandListener(ETHERPAD_COMMAND, conference.addCommandListener(ETHERPAD_COMMAND,
({ value }) => { ({ value }: { value: string; }) => {
let url; let url;
const { etherpad_base: etherpadBase } = getState()['features/base/config']; const { etherpad_base: etherpadBase } = getState()['features/base/config'];

View File

@ -1,5 +1,3 @@
// @flow
import { SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID } from './actionTypes'; import { SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID } from './actionTypes';
/** /**
@ -13,7 +11,7 @@ import { SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID } from './actionTypes';
* uid: number * uid: number
* }} * }}
*/ */
export function setNoAudioSignalNotificationUid(uid: ?number) { export function setNoAudioSignalNotificationUid(uid?: string) {
return { return {
type: SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID, type: SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID,
uid uid

View File

@ -1,20 +1,21 @@
// @flow
import React from 'react'; import React from 'react';
import { AnyAction } from 'redux';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app'; import { IStore } from '../app/types';
import { CONFERENCE_JOINED } from '../base/conference'; import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app/actionTypes';
import { import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
formatDeviceLabel, import { setAudioInputDevice } from '../base/devices/actions';
setAudioInputDevice import { formatDeviceLabel } from '../base/devices/functions';
} from '../base/devices';
import JitsiMeetJS, { JitsiConferenceEvents } from '../base/lib-jitsi-meet'; import JitsiMeetJS, { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import { MiddlewareRegistry } from '../base/redux'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { updateSettings } from '../base/settings'; import { updateSettings } from '../base/settings/actions';
import { playSound, registerSound, unregisterSound } from '../base/sounds'; import { playSound, registerSound, unregisterSound } from '../base/sounds/actions';
import { NOTIFICATION_TIMEOUT_TYPE, hideNotification, showNotification } from '../notifications'; import { hideNotification, showNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { setNoAudioSignalNotificationUid } from './actions'; import { setNoAudioSignalNotificationUid } from './actions';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import DialInLink from './components/DialInLink'; import DialInLink from './components/DialInLink';
import { NO_AUDIO_SIGNAL_SOUND_ID } from './constants'; import { NO_AUDIO_SIGNAL_SOUND_ID } from './constants';
import { NO_AUDIO_SIGNAL_SOUND_FILE } from './sounds'; import { NO_AUDIO_SIGNAL_SOUND_FILE } from './sounds';
@ -48,11 +49,11 @@ MiddlewareRegistry.register(store => next => async action => {
* @private * @private
* @returns {void} * @returns {void}
*/ */
async function _handleNoAudioSignalNotification({ dispatch, getState }, action) { async function _handleNoAudioSignalNotification({ dispatch, getState }: IStore, action: AnyAction) {
const { conference } = action; const { conference } = action;
conference.on(JitsiConferenceEvents.AUDIO_INPUT_STATE_CHANGE, hasAudioInput => { conference.on(JitsiConferenceEvents.AUDIO_INPUT_STATE_CHANGE, (hasAudioInput: boolean) => {
const { noAudioSignalNotificationUid } = getState()['features/no-audio-signal']; const { noAudioSignalNotificationUid } = getState()['features/no-audio-signal'];
// In case the notification is displayed but the conference detected audio input signal we hide it. // In case the notification is displayed but the conference detected audio input signal we hide it.

View File

@ -4,7 +4,7 @@ import { set } from '../base/redux/functions';
import { SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID } from './actionTypes'; import { SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID } from './actionTypes';
export interface INoAudioSignalState { export interface INoAudioSignalState {
noAudioSignalNotificationUid?: number; noAudioSignalNotificationUid?: string;
} }
/** /**

View File

@ -1,5 +1,3 @@
// @flow
import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes'; import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes';
/** /**
@ -13,7 +11,7 @@ import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes';
* uid: number * uid: number
* }} * }}
*/ */
export function setNoisyAudioInputNotificationUid(uid: ?number) { export function setNoisyAudioInputNotificationUid(uid?: string) {
return { return {
type: SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID, type: SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID,
uid uid

View File

@ -1,11 +1,10 @@
// @flow import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app/actionTypes';
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
import { CONFERENCE_JOINED } from '../base/conference';
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet'; import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import { MiddlewareRegistry } from '../base/redux'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { playSound, registerSound, unregisterSound } from '../base/sounds'; import { playSound, registerSound, unregisterSound } from '../base/sounds/actions';
import { NOTIFICATION_TIMEOUT_TYPE, hideNotification, showNotification } from '../notifications'; import { hideNotification, showNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { setNoisyAudioInputNotificationUid } from './actions'; import { setNoisyAudioInputNotificationUid } from './actions';
import { NOISY_AUDIO_INPUT_SOUND_ID } from './constants'; import { NOISY_AUDIO_INPUT_SOUND_ID } from './constants';
@ -27,7 +26,7 @@ MiddlewareRegistry.register(store => next => action => {
conference.on( conference.on(
JitsiConferenceEvents.TRACK_MUTE_CHANGED, JitsiConferenceEvents.TRACK_MUTE_CHANGED,
track => { (track: any) => {
const { noisyAudioInputNotificationUid } = getState()['features/noise-detection']; const { noisyAudioInputNotificationUid } = getState()['features/noise-detection'];
// Hide the notification in case the user mutes the microphone // Hide the notification in case the user mutes the microphone

View File

@ -4,7 +4,7 @@ import { set } from '../base/redux/functions';
import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes'; import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes';
export interface INoiseDetectionState { export interface INoiseDetectionState {
noisyAudioInputNotificationUid?: number; noisyAudioInputNotificationUid?: string;
} }
/** /**

View File

@ -19,6 +19,7 @@ import {
SILENT_JOIN_THRESHOLD, SILENT_JOIN_THRESHOLD,
SILENT_LEFT_THRESHOLD SILENT_LEFT_THRESHOLD
} from './constants'; } from './constants';
import { INotificationProps } from './types';
/** /**
* Function that returns notification timeout value based on notification timeout type. * Function that returns notification timeout value based on notification timeout type.
@ -89,23 +90,6 @@ export function setNotificationsEnabled(enabled: boolean) {
}; };
} }
interface INotificationProps {
appearance?: string;
concatText?: boolean;
customActionHandler?: Function[];
customActionNameKey?: string[];
description?: string;
descriptionKey?: string;
icon?: string;
sticky?: boolean;
title?: string;
titleArguments?: {
[key: string]: string;
};
titleKey?: string;
uid?: string;
}
/** /**
* Queues an error notification for display. * Queues an error notification for display.
* *

View File

@ -0,0 +1,20 @@
import React from 'react';
export interface INotificationProps {
appearance?: string;
concatText?: boolean;
customActionHandler?: Function[];
customActionNameKey?: string[];
description?: string | React.ReactNode;
descriptionArguments?: Object;
descriptionKey?: string;
icon?: string;
maxLines?: number;
sticky?: boolean;
title?: string;
titleArguments?: {
[key: string]: string;
};
titleKey?: string;
uid?: string;
}

View File

@ -1,5 +1,3 @@
// @flow
import { import {
PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_CLOSE,
PARTICIPANTS_PANE_OPEN PARTICIPANTS_PANE_OPEN

View File

@ -1,18 +1,24 @@
import type { Dispatch } from 'redux'; /* eslint-disable lines-around-comment */
import { IStore } from '../app/types';
import { openSheet } from '../base/dialog'; import { openSheet } from '../base/dialog/actions';
// @ts-ignore
import { SharedVideoMenu } from '../video-menu'; import { SharedVideoMenu } from '../video-menu';
// @ts-ignore
import { LocalVideoMenu } from '../video-menu/components/native'; import { LocalVideoMenu } from '../video-menu/components/native';
import ConnectionStatusComponent import ConnectionStatusComponent
// @ts-ignore
from '../video-menu/components/native/ConnectionStatusComponent'; from '../video-menu/components/native/ConnectionStatusComponent';
// @ts-ignore
import RemoteVideoMenu from '../video-menu/components/native/RemoteVideoMenu'; import RemoteVideoMenu from '../video-menu/components/native/RemoteVideoMenu';
import { SET_VOLUME } from './actionTypes'; import { SET_VOLUME } from './actionTypes';
import { import {
ContextMenuLobbyParticipantReject ContextMenuLobbyParticipantReject
// @ts-ignore
} from './components/native'; } from './components/native';
import RoomParticipantMenu from './components/native/RoomParticipantMenu'; import RoomParticipantMenu from './components/native/RoomParticipantMenu';
export * from './actions.any'; export * from './actions.any';
/* eslint-enable lines-around-comment */
/** /**
* Displays the context menu for the selected lobby participant. * Displays the context menu for the selected lobby participant.
@ -42,8 +48,8 @@ export function showConnectionStatus(participantID: string) {
* @param {boolean} local - Whether the participant is local or not. * @param {boolean} local - Whether the participant is local or not.
* @returns {Function} * @returns {Function}
*/ */
export function showContextMenuDetails(participantId: string, local: boolean = false) { export function showContextMenuDetails(participantId: string, local = false) {
return (dispatch: Dispatch<any>, getState: Function) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { remoteVideoMenu } = getState()['features/base/config']; const { remoteVideoMenu } = getState()['features/base/config'];
if (local) { if (local) {
@ -92,6 +98,7 @@ export function setVolume(participantId: string, volume: number) {
* @returns {Function} * @returns {Function}
*/ */
export function showRoomParticipantMenu(room: Object, participantJid: string, participantName: string) { export function showRoomParticipantMenu(room: Object, participantJid: string, participantName: string) {
// @ts-ignore
return openSheet(RoomParticipantMenu, { room, return openSheet(RoomParticipantMenu, { room,
participantJid, participantJid,
participantName }); participantName });

View File

@ -1,3 +1 @@
// @flow
export * from './actions.any'; export * from './actions.any';

View File

@ -2,8 +2,15 @@ import { useCallback, useState } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { handleLobbyChatInitialized } from '../chat/actions.any'; import { handleLobbyChatInitialized } from '../chat/actions.any';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { approveKnockingParticipant, rejectKnockingParticipant } from '../lobby/actions'; import { approveKnockingParticipant, rejectKnockingParticipant } from '../lobby/actions';
interface DrawerParticipant {
displayName?: string;
participantID: string;
}
/** /**
* Hook used to create admit/reject lobby actions. * Hook used to create admit/reject lobby actions.
* *
@ -11,23 +18,23 @@ import { approveKnockingParticipant, rejectKnockingParticipant } from '../lobby/
* @param {Function} closeDrawer - Callback for closing the drawer. * @param {Function} closeDrawer - Callback for closing the drawer.
* @returns {Array<Function>} * @returns {Array<Function>}
*/ */
export function useLobbyActions(participant, closeDrawer) { export function useLobbyActions(participant?: DrawerParticipant | null, closeDrawer?: Function) {
const dispatch = useDispatch(); const dispatch = useDispatch();
return [ return [
useCallback(e => { useCallback(e => {
e.stopPropagation(); e.stopPropagation();
dispatch(approveKnockingParticipant(participant && participant.participantID)); dispatch(approveKnockingParticipant(participant?.participantID));
closeDrawer && closeDrawer(); closeDrawer?.();
}, [ dispatch, closeDrawer ]), }, [ dispatch, closeDrawer ]),
useCallback(() => { useCallback(() => {
dispatch(rejectKnockingParticipant(participant && participant.participantID)); dispatch(rejectKnockingParticipant(participant?.participantID));
closeDrawer && closeDrawer(); closeDrawer?.();
}, [ dispatch, closeDrawer ]), }, [ dispatch, closeDrawer ]),
useCallback(() => { useCallback(() => {
dispatch(handleLobbyChatInitialized(participant && participant.participantID)); dispatch(handleLobbyChatInitialized(participant?.participantID ?? ''));
}, [ dispatch ]) }, [ dispatch ])
]; ];
} }
@ -37,11 +44,14 @@ export function useLobbyActions(participant, closeDrawer) {
* *
* @returns {Array<any>} * @returns {Array<any>}
*/ */
export function useParticipantDrawer() { export function useParticipantDrawer(): [
const [ drawerParticipant, openDrawerForParticipant ] = useState(null); DrawerParticipant | null,
() => void,
(p: DrawerParticipant | null) => void ] {
const [ drawerParticipant, openDrawerForParticipant ] = useState<DrawerParticipant | null>(null);
const closeDrawer = useCallback(() => { const closeDrawer = useCallback(() => {
openDrawerForParticipant(null); openDrawerForParticipant(null);
}); }, []);
return [ return [
drawerParticipant, drawerParticipant,