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

This commit is contained in:
Robert Pintilii 2022-10-21 10:33:10 +03:00 committed by GitHub
parent 9e1ac3bea6
commit 0b48e55a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 81 deletions

View File

@ -70,6 +70,7 @@ export interface IJitsiConference {
sendFeedback: Function; sendFeedback: Function;
sendLobbyMessage: Function; sendLobbyMessage: Function;
sessionId: string; sessionId: string;
setDesktopSharingFrameRate: Function;
setDisplayName: Function; setDisplayName: Function;
setLocalParticipantProperty: Function; setLocalParticipantProperty: Function;
setSubject: Function; setSubject: Function;

View File

@ -1,16 +1,15 @@
// @flow import { IStore } from '../app/types';
import { openDialog } from '../base/dialog/actions'; import { openDialog } from '../base/dialog/actions';
import { browser } from '../base/lib-jitsi-meet'; import { browser } from '../base/lib-jitsi-meet';
import { shouldHideShareAudioHelper } from '../base/settings'; import { shouldHideShareAudioHelper } from '../base/settings/functions';
import { toggleScreensharing } from '../base/tracks'; import { toggleScreensharing } from '../base/tracks/actions';
import { import {
SET_SCREENSHARE_CAPTURE_FRAME_RATE, SET_SCREENSHARE_CAPTURE_FRAME_RATE,
SET_SCREENSHARE_TRACKS, SET_SCREENSHARE_TRACKS,
SET_SCREEN_AUDIO_SHARE_STATE SET_SCREEN_AUDIO_SHARE_STATE
} from './actionTypes'; } from './actionTypes';
import { ShareAudioDialog } from './components'; import ShareAudioDialog from './components/ShareAudioDialog';
import ShareMediaWarningDialog from './components/ShareScreenWarningDialog'; import ShareMediaWarningDialog from './components/ShareScreenWarningDialog';
import { isAudioOnlySharing, isScreenVideoShared } from './functions'; import { isAudioOnlySharing, isScreenVideoShared } from './functions';
@ -55,7 +54,7 @@ export function setScreenshareFramerate(captureFrameRate: number) {
* desktopAudioTrack: JitsiTrack * desktopAudioTrack: JitsiTrack
* }} * }}
*/ */
export function setScreenshareAudioTrack(desktopAudioTrack) { export function setScreenshareAudioTrack(desktopAudioTrack: any) {
return { return {
type: SET_SCREENSHARE_TRACKS, type: SET_SCREENSHARE_TRACKS,
desktopAudioTrack desktopAudioTrack
@ -69,12 +68,12 @@ export function setScreenshareAudioTrack(desktopAudioTrack) {
* @returns {void} * @returns {void}
*/ */
export function startAudioScreenShareFlow() { export function startAudioScreenShareFlow() {
return (dispatch: Object => Object, getState: () => any) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState(); const state = getState();
const audioOnlySharing = isAudioOnlySharing(state); const audioOnlySharing = isAudioOnlySharing(state);
// If we're already in a normal screen sharing session, warn the user. // If we're already in a normal screen sharing session, warn the user.
if (isScreenVideoShared(state)) { if (isScreenVideoShared(state)) { // @ts-ignore
dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: true })); dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: true }));
return; return;
@ -92,6 +91,7 @@ export function startAudioScreenShareFlow() {
return; return;
} }
// @ts-ignore
dispatch(openDialog(ShareAudioDialog)); dispatch(openDialog(ShareAudioDialog));
}; };
} }
@ -104,12 +104,12 @@ export function startAudioScreenShareFlow() {
* @returns {void} * @returns {void}
*/ */
export function startScreenShareFlow(enabled: boolean) { export function startScreenShareFlow(enabled: boolean) {
return (dispatch: Object => Object, getState: () => any) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState(); const state = getState();
const audioOnlySharing = isAudioOnlySharing(state); const audioOnlySharing = isAudioOnlySharing(state);
// If we're in an audio screen sharing session, warn the user. // If we're in an audio screen sharing session, warn the user.
if (audioOnlySharing) { if (audioOnlySharing) { // @ts-ignore
dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: false })); dispatch(openDialog(ShareMediaWarningDialog, { _isAudioScreenShareWarning: false }));
return; return;

View File

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

View File

@ -1,14 +1,11 @@
// @flow import { IStore } from '../app/types';
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import { CONFERENCE_JOINED } from '../base/conference'; import { MEDIA_TYPE } from '../base/media/constants';
import { MEDIA_TYPE } from '../base/media'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { MiddlewareRegistry } from '../base/redux';
import { SET_SCREENSHARE_CAPTURE_FRAME_RATE, SET_SCREEN_AUDIO_SHARE_STATE } from './actionTypes'; import { SET_SCREENSHARE_CAPTURE_FRAME_RATE, SET_SCREEN_AUDIO_SHARE_STATE } from './actionTypes';
import logger from './logger'; import logger from './logger';
declare var APP: Object;
/** /**
* Implements the middleware of the feature screen-share. * Implements the middleware of the feature screen-share.
* *
@ -57,7 +54,7 @@ MiddlewareRegistry.register(store => next => action => {
* @private * @private
* @returns {void} * @returns {void}
*/ */
function _setScreenshareCaptureFps(store, frameRate) { function _setScreenshareCaptureFps(store: IStore, frameRate?: number) {
const state = store.getState(); const state = store.getState();
const { conference } = state['features/base/conference']; const { conference } = state['features/base/conference'];
const { captureFrameRate } = state['features/screen-share']; const { captureFrameRate } = state['features/screen-share'];

View File

@ -1,21 +1,22 @@
// @flow
import { batch } from 'react-redux'; import { batch } from 'react-redux';
import { IStore } from '../app/types';
import { import {
setFollowMe, setFollowMe,
setStartMutedPolicy, setStartMutedPolicy,
setStartReactionsMuted setStartReactionsMuted
} from '../base/conference'; } from '../base/conference/actions';
import { openDialog } from '../base/dialog'; import { openDialog } from '../base/dialog/actions';
import { i18next } from '../base/i18n'; import i18next from '../base/i18n/i18next';
import { updateSettings } from '../base/settings'; import { updateSettings } from '../base/settings/actions';
import { setScreenshareFramerate } from '../screen-share/actions'; import { setScreenshareFramerate } from '../screen-share/actions';
import { import {
SET_AUDIO_SETTINGS_VISIBILITY, SET_AUDIO_SETTINGS_VISIBILITY,
SET_VIDEO_SETTINGS_VISIBILITY SET_VIDEO_SETTINGS_VISIBILITY
} from './actionTypes'; } from './actionTypes';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { LogoutDialog, SettingsDialog } from './components'; import { LogoutDialog, SettingsDialog } from './components';
import { import {
getModeratorTabProps, getModeratorTabProps,
@ -24,8 +25,6 @@ import {
getSoundsTabProps getSoundsTabProps
} from './functions'; } from './functions';
declare var APP: Object;
/** /**
* Opens {@code LogoutDialog}. * Opens {@code LogoutDialog}.
* *
@ -46,7 +45,7 @@ export function openLogoutDialog(onLogout: Function) {
* welcome page or not. * welcome page or not.
* @returns {Function} * @returns {Function}
*/ */
export function openSettingsDialog(defaultTab: string, isDisplayedOnWelcomePage: boolean) { export function openSettingsDialog(defaultTab: string, isDisplayedOnWelcomePage?: boolean) {
return openDialog(SettingsDialog, { return openDialog(SettingsDialog, {
defaultTab, defaultTab,
isDisplayedOnWelcomePage isDisplayedOnWelcomePage
@ -85,8 +84,8 @@ function setVideoSettingsVisibility(value: boolean) {
* @param {Object} newState - The new settings. * @param {Object} newState - The new settings.
* @returns {Function} * @returns {Function}
*/ */
export function submitMoreTab(newState: Object): Function { export function submitMoreTab(newState: any) {
return (dispatch, getState) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const currentState = getMoreTabProps(getState()); const currentState = getMoreTabProps(getState());
const showPrejoinPage = newState.showPrejoinPage; const showPrejoinPage = newState.showPrejoinPage;
@ -134,8 +133,8 @@ export function submitMoreTab(newState: Object): Function {
* @param {Object} newState - The new settings. * @param {Object} newState - The new settings.
* @returns {Function} * @returns {Function}
*/ */
export function submitModeratorTab(newState: Object): Function { export function submitModeratorTab(newState: any) {
return (dispatch, getState) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const currentState = getModeratorTabProps(getState()); const currentState = getModeratorTabProps(getState());
if (newState.followMeEnabled !== currentState.followMeEnabled) { if (newState.followMeEnabled !== currentState.followMeEnabled) {
@ -164,8 +163,8 @@ export function submitModeratorTab(newState: Object): Function {
* @param {Object} newState - The new settings. * @param {Object} newState - The new settings.
* @returns {Function} * @returns {Function}
*/ */
export function submitProfileTab(newState: Object): Function { export function submitProfileTab(newState: any) {
return (dispatch, getState) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const currentState = getProfileTabProps(getState()); const currentState = getProfileTabProps(getState());
if (newState.displayName !== currentState.displayName) { if (newState.displayName !== currentState.displayName) {
@ -184,8 +183,8 @@ export function submitProfileTab(newState: Object): Function {
* @param {Object} newState - The new settings. * @param {Object} newState - The new settings.
* @returns {Function} * @returns {Function}
*/ */
export function submitSoundsTab(newState: Object): Function { export function submitSoundsTab(newState: any) {
return (dispatch, getState) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const currentState = getSoundsTabProps(getState()); const currentState = getSoundsTabProps(getState());
const shouldNotUpdateReactionSounds = getModeratorTabProps(getState()).startReactionsMuted; const shouldNotUpdateReactionSounds = getModeratorTabProps(getState()).startReactionsMuted;
const shouldUpdate = (newState.soundsIncomingMessage !== currentState.soundsIncomingMessage) const shouldUpdate = (newState.soundsIncomingMessage !== currentState.soundsIncomingMessage)
@ -219,7 +218,7 @@ export function submitSoundsTab(newState: Object): Function {
* @returns {void} * @returns {void}
*/ */
export function toggleAudioSettings() { export function toggleAudioSettings() {
return (dispatch: Function, getState: Function) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const value = getState()['features/settings'].audioSettingsVisible; const value = getState()['features/settings'].audioSettingsVisible;
dispatch(setAudioSettingsVisibility(!value)); dispatch(setAudioSettingsVisibility(!value));
@ -232,7 +231,7 @@ export function toggleAudioSettings() {
* @returns {void} * @returns {void}
*/ */
export function toggleVideoSettings() { export function toggleVideoSettings() {
return (dispatch: Function, getState: Function) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const value = getState()['features/settings'].videoSettingsVisible; const value = getState()['features/settings'].videoSettingsVisible;
dispatch(setVideoSettingsVisibility(!value)); dispatch(setVideoSettingsVisibility(!value));

View File

@ -1,25 +1,27 @@
// @flow /* eslint-disable lines-around-comment */
import { IReduxState } from '../app/types';
import { isNameReadOnly } from '../base/config'; import { IStateful } from '../base/app/types';
import { SERVER_URL_CHANGE_ENABLED, getFeatureFlag } from '../base/flags'; import { isNameReadOnly } from '../base/config/functions';
import { DEFAULT_LANGUAGE, LANGUAGES, i18next } from '../base/i18n'; import { SERVER_URL_CHANGE_ENABLED } from '../base/flags/constants';
import { getFeatureFlag } from '../base/flags/functions';
import i18next, { DEFAULT_LANGUAGE, LANGUAGES } from '../base/i18n/i18next';
import { createLocalTrack } from '../base/lib-jitsi-meet/functions'; import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
import { import {
getLocalParticipant, getLocalParticipant,
isLocalParticipantModerator isLocalParticipantModerator
} from '../base/participants'; } from '../base/participants/functions';
import { toState } from '../base/redux'; import { toState } from '../base/redux/functions';
import { getHideSelfView } from '../base/settings'; import { getHideSelfView } from '../base/settings/functions';
import { parseStandardURIString } from '../base/util'; import { parseStandardURIString } from '../base/util/uri';
// @ts-ignore
import { isStageFilmstripEnabled } from '../filmstrip/functions'; import { isStageFilmstripEnabled } from '../filmstrip/functions';
// @ts-ignore
import { isFollowMeActive } from '../follow-me'; import { isFollowMeActive } from '../follow-me';
import { getParticipantsPaneConfig } from '../participants-pane/functions'; import { getParticipantsPaneConfig } from '../participants-pane/functions';
import { isReactionsEnabled } from '../reactions/functions.any'; import { isReactionsEnabled } from '../reactions/functions.any';
import { SS_DEFAULT_FRAME_RATE, SS_SUPPORTED_FRAMERATES } from './constants'; import { SS_DEFAULT_FRAME_RATE, SS_SUPPORTED_FRAMERATES } from './constants';
declare var interfaceConfig: Object;
/** /**
* Used for web. Indicates if the setting section is enabled. * Used for web. Indicates if the setting section is enabled.
* *
@ -39,7 +41,7 @@ export function isSettingEnabled(settingName: string) {
* {@code getState} function to be used to retrieve the state. * {@code getState} function to be used to retrieve the state.
* @returns {boolean} True to indicate that user can change Server URL, false otherwise. * @returns {boolean} True to indicate that user can change Server URL, false otherwise.
*/ */
export function isServerURLChangeEnabled(stateful: Object | Function) { export function isServerURLChangeEnabled(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const flag = getFeatureFlag(state, SERVER_URL_CHANGE_ENABLED, true); const flag = getFeatureFlag(state, SERVER_URL_CHANGE_ENABLED, true);
@ -88,11 +90,15 @@ export function normalizeUserInputURL(url: string) {
* {@code getState} function to be used to retrieve the state. * {@code getState} function to be used to retrieve the state.
* @returns {Object} - The section of notifications to be configured. * @returns {Object} - The section of notifications to be configured.
*/ */
export function getNotificationsMap(stateful: Object | Function) { export function getNotificationsMap(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { notifications } = state['features/base/config']; const { notifications } = state['features/base/config'];
const { userSelectedNotifications } = state['features/base/settings']; const { userSelectedNotifications } = state['features/base/settings'];
if (!userSelectedNotifications) {
return {};
}
return Object.keys(userSelectedNotifications) return Object.keys(userSelectedNotifications)
.filter(key => !notifications || notifications.includes(key)) .filter(key => !notifications || notifications.includes(key))
.reduce((notificationsMap, key) => { .reduce((notificationsMap, key) => {
@ -111,7 +117,7 @@ export function getNotificationsMap(stateful: Object | Function) {
* {@code getState} function to be used to retrieve the state. * {@code getState} function to be used to retrieve the state.
* @returns {Object} - The properties for the "More" tab from settings dialog. * @returns {Object} - The properties for the "More" tab from settings dialog.
*/ */
export function getMoreTabProps(stateful: Object | Function) { export function getMoreTabProps(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const framerate = state['features/screen-share'].captureFrameRate ?? SS_DEFAULT_FRAME_RATE; const framerate = state['features/screen-share'].captureFrameRate ?? SS_DEFAULT_FRAME_RATE;
const language = i18next.language || DEFAULT_LANGUAGE; const language = i18next.language || DEFAULT_LANGUAGE;
@ -147,7 +153,7 @@ export function getMoreTabProps(stateful: Object | Function) {
* {@code getState} function to be used to retrieve the state. * {@code getState} function to be used to retrieve the state.
* @returns {Object} - The properties for the "More" tab from settings dialog. * @returns {Object} - The properties for the "More" tab from settings dialog.
*/ */
export function getModeratorTabProps(stateful: Object | Function) { export function getModeratorTabProps(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { const {
conference, conference,
@ -179,7 +185,7 @@ export function getModeratorTabProps(stateful: Object | Function) {
* {@code getState} function to be used to retrieve the state. * {@code getState} function to be used to retrieve the state.
* @returns {boolean} True to indicate that moderator tab should be visible, false otherwise. * @returns {boolean} True to indicate that moderator tab should be visible, false otherwise.
*/ */
export function shouldShowModeratorSettings(stateful: Object | Function) { export function shouldShowModeratorSettings(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { hideModeratorSettingsTab } = getParticipantsPaneConfig(state); const { hideModeratorSettingsTab } = getParticipantsPaneConfig(state);
const hasModeratorRights = Boolean(isSettingEnabled('moderator') && isLocalParticipantModerator(state)); const hasModeratorRights = Boolean(isSettingEnabled('moderator') && isLocalParticipantModerator(state));
@ -196,7 +202,7 @@ export function shouldShowModeratorSettings(stateful: Object | Function) {
* @returns {Object} - The properties for the "Profile" tab from settings * @returns {Object} - The properties for the "Profile" tab from settings
* dialog. * dialog.
*/ */
export function getProfileTabProps(stateful: Object | Function) { export function getProfileTabProps(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { const {
authEnabled, authEnabled,
@ -209,8 +215,8 @@ export function getProfileTabProps(stateful: Object | Function) {
return { return {
authEnabled: Boolean(conference && authEnabled), authEnabled: Boolean(conference && authEnabled),
authLogin, authLogin,
displayName: localParticipant.name, displayName: localParticipant?.name,
email: localParticipant.email, email: localParticipant?.email,
readOnlyName: isNameReadOnly(state), readOnlyName: isNameReadOnly(state),
hideEmailInSettings hideEmailInSettings
}; };
@ -225,7 +231,7 @@ export function getProfileTabProps(stateful: Object | Function) {
* @returns {Object} - The properties for the "Sounds" tab from settings * @returns {Object} - The properties for the "Sounds" tab from settings
* dialog. * dialog.
*/ */
export function getSoundsTabProps(stateful: Object | Function) { export function getSoundsTabProps(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
const { const {
soundsIncomingMessage, soundsIncomingMessage,
@ -259,9 +265,9 @@ export function getSoundsTabProps(stateful: Object | Function) {
* *
* @returns {Promise<Object[]>} * @returns {Promise<Object[]>}
*/ */
export function createLocalVideoTracks(ids: string[], timeout: ?number) { export function createLocalVideoTracks(ids: string[], timeout?: number) {
return Promise.all(ids.map(deviceId => createLocalTrack('video', deviceId, timeout) return Promise.all(ids.map(deviceId => createLocalTrack('video', deviceId, timeout)
.then(jitsiTrack => { .then((jitsiTrack: any) => {
return { return {
jitsiTrack, jitsiTrack,
deviceId deviceId
@ -290,7 +296,7 @@ export function createLocalVideoTracks(ids: string[], timeout: ?number) {
* label: string * label: string
* }[]>} * }[]>}
*/ */
export function createLocalAudioTracks(devices: Object[], timeout: ?number) { export function createLocalAudioTracks(devices: MediaDeviceInfo[], timeout?: number) {
return Promise.all( return Promise.all(
devices.map(async ({ deviceId, label }) => { devices.map(async ({ deviceId, label }) => {
let jitsiTrack = null; let jitsiTrack = null;
@ -317,7 +323,7 @@ export function createLocalAudioTracks(devices: Object[], timeout: ?number) {
* @param {Object} state - The state of the application. * @param {Object} state - The state of the application.
* @returns {boolean} * @returns {boolean}
*/ */
export function getAudioSettingsVisibility(state: Object) { export function getAudioSettingsVisibility(state: IReduxState) {
return state['features/settings'].audioSettingsVisible; return state['features/settings'].audioSettingsVisible;
} }
@ -327,6 +333,6 @@ export function getAudioSettingsVisibility(state: Object) {
* @param {Object} state - The state of the application. * @param {Object} state - The state of the application.
* @returns {boolean} * @returns {boolean}
*/ */
export function getVideoSettingsVisibility(state: Object) { export function getVideoSettingsVisibility(state: IReduxState) {
return state['features/settings'].videoSettingsVisible; return state['features/settings'].videoSettingsVisible;
} }

View File

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

View File

@ -1,6 +1,8 @@
import { MiddlewareRegistry } from '../base/redux'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { SETTINGS_UPDATED, getHideSelfView } from '../base/settings'; import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE, showNotification } from '../notifications'; import { getHideSelfView } from '../base/settings/functions';
import { showNotification } from '../notifications/actions';
import { DISABLE_SELF_VIEW_NOTIFICATION_ID, NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { openSettingsDialog } from './actions'; import { openSettingsDialog } from './actions';
import { SETTINGS_TABS } from './constants'; import { SETTINGS_TABS } from './constants';