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

This commit is contained in:
Robert Pintilii 2022-10-27 10:33:11 +03:00 committed by GitHub
parent b4809fe083
commit 9f5a56bbc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 145 additions and 159 deletions

View File

@ -50,6 +50,7 @@ export interface IJitsiConference {
getBreakoutRooms: Function; getBreakoutRooms: Function;
getLocalParticipantProperty: Function; getLocalParticipantProperty: Function;
getLocalTracks: Function; getLocalTracks: Function;
getParticipantById: Function;
grantOwner: Function; grantOwner: Function;
isAVModerationSupported: Function; isAVModerationSupported: Function;
isCallstatsEnabled: Function; isCallstatsEnabled: Function;
@ -74,6 +75,8 @@ export interface IJitsiConference {
setDesktopSharingFrameRate: Function; setDesktopSharingFrameRate: Function;
setDisplayName: Function; setDisplayName: Function;
setLocalParticipantProperty: Function; setLocalParticipantProperty: Function;
setReceiverConstraints: Function;
setSenderVideoConstraint: Function;
setSubject: Function; setSubject: Function;
} }

View File

@ -433,7 +433,7 @@ export interface IConfig {
disableSearch?: boolean; disableSearch?: boolean;
disabled?: boolean; disabled?: boolean;
order?: Array<'role' | 'name' | 'hasLeft'>; order?: Array<'role' | 'name' | 'hasLeft'>;
}; };
speakerStatsOrder?: Array<'role' | 'name' | 'hasLeft'>; speakerStatsOrder?: Array<'role' | 'name' | 'hasLeft'>;
startAudioMuted?: number; startAudioMuted?: number;
startAudioOnly?: boolean; startAudioOnly?: boolean;
@ -492,6 +492,7 @@ export interface IConfig {
minHeightForQualityLvl?: { minHeightForQualityLvl?: {
[key: number]: string; [key: number]: string;
}; };
persist?: boolean;
preferredCodec?: string; preferredCodec?: string;
resizeDesktopForPresenter?: boolean; resizeDesktopForPresenter?: boolean;
}; };

View File

@ -496,7 +496,7 @@ export function getVirtualScreenshareParticipantTrack(tracks: ITrack[], virtualS
* @param {string[]} screenShareParticipantIds - Participant ID. * @param {string[]} screenShareParticipantIds - Participant ID.
* @returns {(string[])} * @returns {(string[])}
*/ */
export function getRemoteScreenSharesSourceNames(state: IReduxState, screenShareParticipantIds = []) { export function getRemoteScreenSharesSourceNames(state: IReduxState, screenShareParticipantIds: string[] = []) {
const tracks = state['features/base/tracks']; const tracks = state['features/base/tracks'];
return getMultipleVideoSupportFeatureFlag(state) return getMultipleVideoSupportFeatureFlag(state)

View File

@ -1,5 +1,3 @@
// @flow
import { import {
SET_FOLLOW_ME_MODERATOR, SET_FOLLOW_ME_MODERATOR,
SET_FOLLOW_ME_STATE SET_FOLLOW_ME_STATE
@ -14,7 +12,7 @@ import {
* id, string * id, string
* }} * }}
*/ */
export function setFollowMeModerator(id: ?string) { export function setFollowMeModerator(id?: string) {
return { return {
type: SET_FOLLOW_ME_MODERATOR, type: SET_FOLLOW_ME_MODERATOR,
id id
@ -30,7 +28,7 @@ export function setFollowMeModerator(id: ?string) {
* state: Object * state: Object
* }} * }}
*/ */
export function setFollowMeState(state: ?Object) { export function setFollowMeState(state?: Object) {
return { return {
type: SET_FOLLOW_ME_STATE, type: SET_FOLLOW_ME_STATE,
state state

View File

@ -1,6 +1,5 @@
// @flow import { IStateful } from '../base/app/types';
import { toState } from '../base/redux/functions';
import { toState } from '../base/redux';
/** /**
* Returns true if follow me is active and false otherwise. * Returns true if follow me is active and false otherwise.
@ -9,7 +8,7 @@ import { toState } from '../base/redux';
* to the Redux state. * to the Redux state.
* @returns {boolean} - True if follow me is active and false otherwise. * @returns {boolean} - True if follow me is active and false otherwise.
*/ */
export function isFollowMeActive(stateful: Object | Function) { export function isFollowMeActive(stateful: IStateful) {
const state = toState(stateful); const state = toState(stateful);
return Boolean(state['features/follow-me'].moderator); return Boolean(state['features/follow-me'].moderator);

View File

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

View File

@ -1,19 +1,16 @@
// @flow
import _ from 'lodash'; import _ from 'lodash';
import { IStore } from '../app/types';
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes'; import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
import { import { PARTICIPANT_LEFT } from '../base/participants/actionTypes';
PARTICIPANT_LEFT, import { pinParticipant } from '../base/participants/actions';
getParticipantById, import { getParticipantById, getPinnedParticipant } from '../base/participants/functions';
getPinnedParticipant, import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
pinParticipant import { updateSettings } from '../base/settings/actions';
} from '../base/participants'; // eslint-disable-next-line lines-around-comment
import { MiddlewareRegistry } from '../base/redux'; // @ts-ignore
import { updateSettings } from '../base/settings'; import { addStageParticipant, setFilmstripVisible } from '../filmstrip/actions';
import { setFilmstripVisible } from '../filmstrip'; import { setTileView } from '../video-layout/actions.any';
import { addStageParticipant } from '../filmstrip/actions.web';
import { setTileView } from '../video-layout';
import { import {
setFollowMeModerator, setFollowMeModerator,
@ -25,8 +22,6 @@ import logger from './logger';
import './subscriber'; import './subscriber';
declare var APP: Object;
/** /**
* The timeout after which a follow-me command that has been received will be * The timeout after which a follow-me command that has been received will be
* ignored if not consumed. * ignored if not consumed.
@ -43,7 +38,7 @@ const _FOLLOW_ME_RECEIVED_TIMEOUT = 30;
* *
* @type {TimeoutID} * @type {TimeoutID}
*/ */
let nextOnStageTimeout; let nextOnStageTimeout: number;
/** /**
* A count of how many seconds the nextOnStageTimeout has ticked while waiting * A count of how many seconds the nextOnStageTimeout has ticked while waiting
@ -66,7 +61,7 @@ MiddlewareRegistry.register(store => next => action => {
const { conference } = action; const { conference } = action;
conference.addCommandListener( conference.addCommandListener(
FOLLOW_ME_COMMAND, ({ attributes }, id) => { FOLLOW_ME_COMMAND, ({ attributes }: any, id: string) => {
_onFollowMeCommand(attributes, id, store); _onFollowMeCommand(attributes, id, store);
}); });
break; break;
@ -94,7 +89,7 @@ MiddlewareRegistry.register(store => next => action => {
* @private * @private
* @returns {void} * @returns {void}
*/ */
function _onFollowMeCommand(attributes = {}, id, store) { function _onFollowMeCommand(attributes: any = {}, id: string, store: IStore) {
const state = store.getState(); const state = store.getState();
// We require to know who issued the command because (1) only a // We require to know who issued the command because (1) only a
@ -124,7 +119,7 @@ function _onFollowMeCommand(attributes = {}, id, store) {
const { conference } = state['features/base/conference']; const { conference } = state['features/base/conference'];
// As this participant is not stored in redux store we do the checks on the JitsiParticipant from lib-jitsi-meet // As this participant is not stored in redux store we do the checks on the JitsiParticipant from lib-jitsi-meet
const participant = conference.getParticipantById(id); const participant = conference?.getParticipantById(id);
if (!iAmRecorder || !participant || participant.getRole() !== 'moderator' if (!iAmRecorder || !participant || participant.getRole() !== 'moderator'
|| !participant.isHiddenFromRecorder()) { || !participant.isHiddenFromRecorder()) {
@ -187,7 +182,8 @@ function _onFollowMeCommand(attributes = {}, id, store) {
const stageParticipants = JSON.parse(attributes.pinnedStageParticipants); const stageParticipants = JSON.parse(attributes.pinnedStageParticipants);
if (!_.isEqual(stageParticipants, oldState.pinnedStageParticipants)) { if (!_.isEqual(stageParticipants, oldState.pinnedStageParticipants)) {
stageParticipants.forEach(p => store.dispatch(addStageParticipant(p.participantId, true))); stageParticipants.forEach((p: { participantId: string; }) =>
store.dispatch(addStageParticipant(p.participantId, true)));
} }
} }
@ -207,14 +203,14 @@ function _onFollowMeCommand(attributes = {}, id, store) {
* @private * @private
* @returns {void} * @returns {void}
*/ */
function _pinVideoThumbnailById(store, clickId) { function _pinVideoThumbnailById(store: IStore, clickId: string) {
if (getParticipantById(store.getState(), clickId)) { if (getParticipantById(store.getState(), clickId)) {
clearTimeout(nextOnStageTimeout); clearTimeout(nextOnStageTimeout);
nextOnStageTimer = 0; nextOnStageTimer = 0;
store.dispatch(pinParticipant(clickId)); store.dispatch(pinParticipant(clickId));
} else { } else {
nextOnStageTimeout = setTimeout(() => { nextOnStageTimeout = window.setTimeout(() => {
if (nextOnStageTimer > _FOLLOW_ME_RECEIVED_TIMEOUT) { if (nextOnStageTimer > _FOLLOW_ME_RECEIVED_TIMEOUT) {
nextOnStageTimer = 0; nextOnStageTimer = 0;

View File

@ -1,11 +1,12 @@
// @flow import { IReduxState, IStore } from '../app/types';
import { getCurrentConference } from '../base/conference/functions';
import { getCurrentConference } from '../base/conference';
import { import {
getPinnedParticipant, getPinnedParticipant,
isLocalParticipantModerator isLocalParticipantModerator
} from '../base/participants'; } from '../base/participants/functions';
import { StateListenerRegistry } from '../base/redux'; import StateListenerRegistry from '../base/redux/StateListenerRegistry';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { getPinnedActiveParticipants, isStageFilmstripEnabled } from '../filmstrip/functions.web'; import { getPinnedActiveParticipants, isStageFilmstripEnabled } from '../filmstrip/functions.web';
import { shouldDisplayTileView } from '../video-layout/functions'; import { shouldDisplayTileView } from '../video-layout/functions';
@ -84,14 +85,14 @@ StateListenerRegistry.register(
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {Object} * @returns {Object}
*/ */
function _getFollowMeState(state) { function _getFollowMeState(state: IReduxState) {
const pinnedParticipant = getPinnedParticipant(state); const pinnedParticipant = getPinnedParticipant(state);
const stageFilmstrip = isStageFilmstripEnabled(state); const stageFilmstrip = isStageFilmstripEnabled(state);
return { return {
filmstripVisible: state['features/filmstrip'].visible, filmstripVisible: state['features/filmstrip'].visible,
maxStageParticipants: stageFilmstrip ? state['features/base/settings'].maxStageParticipants : undefined, maxStageParticipants: stageFilmstrip ? state['features/base/settings'].maxStageParticipants : undefined,
nextOnStage: stageFilmstrip ? undefined : pinnedParticipant && pinnedParticipant.id, nextOnStage: stageFilmstrip ? undefined : pinnedParticipant?.id,
pinnedStageParticipants: stageFilmstrip ? JSON.stringify(getPinnedActiveParticipants(state)) : undefined, pinnedStageParticipants: stageFilmstrip ? JSON.stringify(getPinnedActiveParticipants(state)) : undefined,
sharedDocumentVisible: state['features/etherpad'].editing, sharedDocumentVisible: state['features/etherpad'].editing,
tileViewEnabled: shouldDisplayTileView(state) tileViewEnabled: shouldDisplayTileView(state)
@ -107,7 +108,7 @@ function _getFollowMeState(state) {
* @returns {void} * @returns {void}
*/ */
function _sendFollowMeCommand( function _sendFollowMeCommand(
newSelectedValue, store) { // eslint-disable-line no-unused-vars newSelectedValue: any, store: IStore) {
const state = store.getState(); const state = store.getState();
const conference = getCurrentConference(state); const conference = getCurrentConference(state);

View File

@ -1,6 +1,5 @@
// @flow import { IStateful } from '../base/app/types';
import { getFakeParticipants } from '../base/participants/functions';
import { getFakeParticipants } from '../base/participants';
import { VIDEO_PLAYER_PARTICIPANT_NAME, YOUTUBE_PLAYER_PARTICIPANT_NAME } from './constants'; import { VIDEO_PLAYER_PARTICIPANT_NAME, YOUTUBE_PLAYER_PARTICIPANT_NAME } from './constants';
@ -40,10 +39,10 @@ export function isSharingStatus(status: string) {
* @param {Object | Function} stateful - The Redux state or a function that gets resolved to the Redux state. * @param {Object | Function} stateful - The Redux state or a function that gets resolved to the Redux state.
* @returns {boolean} * @returns {boolean}
*/ */
export function isVideoPlaying(stateful: Object | Function): boolean { export function isVideoPlaying(stateful: IStateful): boolean {
let videoPlaying = false; let videoPlaying = false;
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const [ id, p ] of getFakeParticipants(stateful)) { for (const [ id, p ] of getFakeParticipants(stateful)) {
if (p.name === VIDEO_PLAYER_PARTICIPANT_NAME || p.name === YOUTUBE_PLAYER_PARTICIPANT_NAME) { if (p.name === VIDEO_PLAYER_PARTICIPANT_NAME || p.name === YOUTUBE_PLAYER_PARTICIPANT_NAME) {
videoPlaying = true; videoPlaying = true;

View File

@ -1,6 +1,4 @@
// @flow import { IStore } from '../app/types';
import type { Dispatch } from 'redux';
import { import {
SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED, SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED,
@ -54,7 +52,7 @@ export function virtualScreenshareParticipantsUpdated(participantIds: Array<stri
* enabled: ?boolean * enabled: ?boolean
* }} * }}
*/ */
export function setTileView(enabled: ?boolean) { export function setTileView(enabled?: boolean) {
return { return {
type: SET_TILE_VIEW, type: SET_TILE_VIEW,
enabled enabled
@ -68,7 +66,7 @@ export function setTileView(enabled: ?boolean) {
* @returns {Function} * @returns {Function}
*/ */
export function toggleTileView() { export function toggleTileView() {
return (dispatch: Dispatch<any>, getState: Function) => { return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const tileViewActive = shouldDisplayTileView(getState()); const tileViewActive = shouldDisplayTileView(getState());
dispatch(setTileView(!tileViewActive)); dispatch(setTileView(!tileViewActive));

View File

@ -1,13 +1,11 @@
// @flow import { IReduxState, IStore } from '../app/types';
import type { Dispatch } from 'redux'; import { TILE_VIEW_ENABLED } from '../base/flags/constants';
import { getFeatureFlag } from '../base/flags/functions';
import { TILE_VIEW_ENABLED, getFeatureFlag } from '../base/flags'; import { pinParticipant } from '../base/participants/actions';
import { import { getParticipantCount, getPinnedParticipant } from '../base/participants/functions';
getParticipantCount,
getPinnedParticipant,
pinParticipant
} from '../base/participants';
import { FakeParticipant } from '../base/participants/types'; import { FakeParticipant } from '../base/participants/types';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { isStageFilmstripAvailable } from '../filmstrip/functions'; import { isStageFilmstripAvailable } from '../filmstrip/functions';
import { isVideoPlaying } from '../shared-video/functions'; import { isVideoPlaying } from '../shared-video/functions';
import { VIDEO_QUALITY_LEVELS } from '../video-quality/constants'; import { VIDEO_QUALITY_LEVELS } from '../video-quality/constants';
@ -16,8 +14,6 @@ import { getMinHeightForQualityLvlMap } from '../video-quality/selector';
import { LAYOUTS } from './constants'; import { LAYOUTS } from './constants';
declare var interfaceConfig: Object;
/** /**
* A selector for retrieving the current automatic pinning setting. * A selector for retrieving the current automatic pinning setting.
* *
@ -40,7 +36,7 @@ export function getAutoPinSetting() {
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {string} * @returns {string}
*/ */
export function getCurrentLayout(state: Object) { export function getCurrentLayout(state: IReduxState) {
if (navigator.product === 'ReactNative') { if (navigator.product === 'ReactNative') {
// FIXME: what should this return? // FIXME: what should this return?
return undefined; return undefined;
@ -65,8 +61,8 @@ export function getCurrentLayout(state: Object) {
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {boolean} True if tile view should be displayed. * @returns {boolean} True if tile view should be displayed.
*/ */
export function shouldDisplayTileView(state: Object = {}) { export function shouldDisplayTileView(state: IReduxState) {
const { tileViewEnabled } = state['features/video-layout']; const { tileViewEnabled } = state['features/video-layout'] ?? {};
if (tileViewEnabled !== undefined) { if (tileViewEnabled !== undefined) {
// If the user explicitly requested a view mode, we // If the user explicitly requested a view mode, we
@ -119,7 +115,7 @@ export function shouldDisplayTileView(state: Object = {}) {
* @returns {void} * @returns {void}
*/ */
export function updateAutoPinnedParticipant( export function updateAutoPinnedParticipant(
screenShares: Array<string>, { dispatch, getState }: { dispatch: Dispatch<any>, getState: Function }) { screenShares: Array<string>, { dispatch, getState }: IStore) {
const state = getState(); const state = getState();
const remoteScreenShares = state['features/video-layout'].remoteScreenShares; const remoteScreenShares = state['features/video-layout'].remoteScreenShares;
const pinned = getPinnedParticipant(getState); const pinned = getPinnedParticipant(getState);
@ -155,7 +151,7 @@ export function updateAutoPinnedParticipant(
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {boolean} * @returns {boolean}
*/ */
export function isLayoutTileView(state: Object) { export function isLayoutTileView(state: IReduxState) {
return getCurrentLayout(state) === LAYOUTS.TILE_VIEW; return getCurrentLayout(state) === LAYOUTS.TILE_VIEW;
} }
@ -189,7 +185,7 @@ function getVideoQualityForHeight(height: number) {
* @param {Object} state - Redux state. * @param {Object} state - Redux state.
* @returns {number} * @returns {number}
*/ */
export function getVideoQualityForResizableFilmstripThumbnails(height, state) { export function getVideoQualityForResizableFilmstripThumbnails(height: number, state: IReduxState) {
if (!height) { if (!height) {
return VIDEO_QUALITY_LEVELS.LOW; return VIDEO_QUALITY_LEVELS.LOW;
} }
@ -204,7 +200,7 @@ export function getVideoQualityForResizableFilmstripThumbnails(height, state) {
* @param {Object} state - Redux state. * @param {Object} state - Redux state.
* @returns {number} * @returns {number}
*/ */
export function getVideoQualityForScreenSharingFilmstrip(height, state) { export function getVideoQualityForScreenSharingFilmstrip(height: number, state: IReduxState) {
if (!height) { if (!height) {
return VIDEO_QUALITY_LEVELS.LOW; return VIDEO_QUALITY_LEVELS.LOW;
} }
@ -218,7 +214,7 @@ export function getVideoQualityForScreenSharingFilmstrip(height, state) {
* @param {number} largeVideoHeight - The height of the large video. * @param {number} largeVideoHeight - The height of the large video.
* @returns {number} - The video quality for the large video. * @returns {number} - The video quality for the large video.
*/ */
export function getVideoQualityForLargeVideo(largeVideoHeight) { export function getVideoQualityForLargeVideo(largeVideoHeight: number) {
return getVideoQualityForHeight(largeVideoHeight); return getVideoQualityForHeight(largeVideoHeight);
} }
@ -229,7 +225,7 @@ export function getVideoQualityForLargeVideo(largeVideoHeight) {
* @param {Object} state - Redux state. * @param {Object} state - Redux state.
* @returns {number} * @returns {number}
*/ */
export function getVideoQualityForStageThumbnails(height, state) { export function getVideoQualityForStageThumbnails(height: number, state: IReduxState) {
if (!height) { if (!height) {
return VIDEO_QUALITY_LEVELS.LOW; return VIDEO_QUALITY_LEVELS.LOW;
} }

View File

@ -1,3 +1,4 @@
import { IReduxState } from '../app/types';
import { import {
ABSOLUTE_MAX_COLUMNS, ABSOLUTE_MAX_COLUMNS,
DEFAULT_MAX_COLUMNS, DEFAULT_MAX_COLUMNS,
@ -7,12 +8,12 @@ import {
getNumberOfPartipantsForTileView, getNumberOfPartipantsForTileView,
getThumbnailMinHeight, getThumbnailMinHeight,
getTileDefaultAspectRatio getTileDefaultAspectRatio
} from '../filmstrip/functions';
// @ts-ignore
} from '../filmstrip/functions.web';
export * from './functions.any'; export * from './functions.any';
declare var interfaceConfig: Object;
/** /**
* Returns how many columns should be displayed in tile view. The number * Returns how many columns should be displayed in tile view. The number
* returned will be between 1 and 7, inclusive. * returned will be between 1 and 7, inclusive.
@ -24,7 +25,8 @@ declare var interfaceConfig: Object;
* @param {boolean} options.disableTileEnlargement - Custom value to be used instead of config.disableTileEnlargement. * @param {boolean} options.disableTileEnlargement - Custom value to be used instead of config.disableTileEnlargement.
* @returns {number} * @returns {number}
*/ */
export function getMaxColumnCount(state, options = {}) { export function getMaxColumnCount(state: IReduxState, options: {
disableResponsiveTiles?: boolean; disableTileEnlargement?: boolean; width?: number; } = {}) {
if (typeof interfaceConfig === 'undefined') { if (typeof interfaceConfig === 'undefined') {
return DEFAULT_MAX_COLUMNS; return DEFAULT_MAX_COLUMNS;
} }
@ -69,7 +71,7 @@ export function getMaxColumnCount(state, options = {}) {
* @returns {Object} An object is return with the desired number of columns, * @returns {Object} An object is return with the desired number of columns,
* rows, and visible rows (the rest should overflow) for the tile view layout. * rows, and visible rows (the rest should overflow) for the tile view layout.
*/ */
export function getNotResponsiveTileViewGridDimensions(state: Object, stageFilmstrip: boolean = false) { export function getNotResponsiveTileViewGridDimensions(state: IReduxState, stageFilmstrip = false) {
const maxColumns = getMaxColumnCount(state); const maxColumns = getMaxColumnCount(state);
const { activeParticipants } = state['features/filmstrip']; const { activeParticipants } = state['features/filmstrip'];
const numberOfParticipants = stageFilmstrip ? activeParticipants.length : getNumberOfPartipantsForTileView(state); const numberOfParticipants = stageFilmstrip ? activeParticipants.length : getNumberOfPartipantsForTileView(state);

View File

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

View File

@ -1,19 +1,17 @@
// @flow import { IStore } from '../app/types';
import { getCurrentConference } from '../base/conference/functions';
import { getCurrentConference } from '../base/conference'; import { VIDEO_TYPE } from '../base/media/constants';
import { VIDEO_TYPE } from '../base/media'; import { PARTICIPANT_LEFT, PIN_PARTICIPANT } from '../base/participants/actionTypes';
import { import { pinParticipant } from '../base/participants/actions';
PARTICIPANT_LEFT, import { getParticipantById, getPinnedParticipant } from '../base/participants/functions';
PIN_PARTICIPANT, import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
getParticipantById, import StateListenerRegistry from '../base/redux/StateListenerRegistry';
getPinnedParticipant, import { TRACK_REMOVED } from '../base/tracks/actionTypes';
pinParticipant import { SET_DOCUMENT_EDITING_STATUS } from '../etherpad/actionTypes';
} from '../base/participants'; // eslint-disable-next-line lines-around-comment
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux'; // @ts-ignore
import { TRACK_REMOVED } from '../base/tracks';
import { SET_DOCUMENT_EDITING_STATUS } from '../etherpad';
import { isStageFilmstripEnabled } from '../filmstrip/functions'; import { isStageFilmstripEnabled } from '../filmstrip/functions';
import { isFollowMeActive } from '../follow-me'; import { isFollowMeActive } from '../follow-me/functions';
import { SET_TILE_VIEW } from './actionTypes'; import { SET_TILE_VIEW } from './actionTypes';
import { setRemoteParticipantsWithScreenShare, setTileView } from './actions'; import { setRemoteParticipantsWithScreenShare, setTileView } from './actions';
@ -21,7 +19,7 @@ import { getAutoPinSetting, updateAutoPinnedParticipant } from './functions';
import './subscriber'; import './subscriber';
let previousTileViewEnabled; let previousTileViewEnabled: boolean | undefined;
/** /**
* Middleware which intercepts actions and updates tile view related state. * Middleware which intercepts actions and updates tile view related state.
@ -88,7 +86,7 @@ MiddlewareRegistry.register(store => next => action => {
case TRACK_REMOVED: { case TRACK_REMOVED: {
const { jitsiTrack } = action.track; const { jitsiTrack } = action.track;
if (jitsiTrack && jitsiTrack.isVideoTrack() && jitsiTrack.getVideoType() === VIDEO_TYPE.DESKTOP) { if (jitsiTrack?.isVideoTrack() && jitsiTrack?.getVideoType() === VIDEO_TYPE.DESKTOP) {
const participantId = jitsiTrack.getParticipantId(); const participantId = jitsiTrack.getParticipantId();
const oldScreenShares = store.getState()['features/video-layout'].remoteScreenShares || []; const oldScreenShares = store.getState()['features/video-layout'].remoteScreenShares || [];
const newScreenShares = oldScreenShares.filter(id => id !== participantId); const newScreenShares = oldScreenShares.filter(id => id !== participantId);
@ -134,7 +132,7 @@ StateListenerRegistry.register(
* @param {Object} store - The Redux Store. * @param {Object} store - The Redux Store.
* @returns {void} * @returns {void}
*/ */
function _restoreTileViewState({ dispatch, getState }) { function _restoreTileViewState({ dispatch, getState }: IStore) {
const { tileViewEnabled } = getState()['features/video-layout']; const { tileViewEnabled } = getState()['features/video-layout'];
if (tileViewEnabled === undefined && previousTileViewEnabled !== undefined) { if (tileViewEnabled === undefined && previousTileViewEnabled !== undefined) {
@ -150,7 +148,7 @@ function _restoreTileViewState({ dispatch, getState }) {
* @param {Object} store - The Redux Store. * @param {Object} store - The Redux Store.
* @returns {void} * @returns {void}
*/ */
function _storeTileViewStateAndClear({ dispatch, getState }) { function _storeTileViewStateAndClear({ dispatch, getState }: IStore) {
const { tileViewEnabled } = getState()['features/video-layout']; const { tileViewEnabled } = getState()['features/video-layout'];
if (tileViewEnabled !== undefined) { if (tileViewEnabled !== undefined) {

View File

@ -1,6 +1,9 @@
import { MEDIA_TYPE, VIDEO_MUTISM_AUTHORITY, setVideoMuted } from '../base/media'; import { setVideoMuted } from '../base/media/actions';
import { MiddlewareRegistry } from '../base/redux'; import { MEDIA_TYPE, VIDEO_MUTISM_AUTHORITY } from '../base/media/constants';
import { CLIENT_RESIZED } from '../base/responsive-ui'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { CLIENT_RESIZED } from '../base/responsive-ui/actionTypes';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { setLargeVideoDimensions } from '../large-video/actions.any'; import { setLargeVideoDimensions } from '../large-video/actions.any';
import { SET_CAR_MODE } from './actionTypes'; import { SET_CAR_MODE } from './actionTypes';

View File

@ -1,15 +1,11 @@
// @flow // @ts-expect-error
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js'; import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
import { CONFERENCE_WILL_LEAVE } from '../base/conference'; import { CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
import { MEDIA_TYPE } from '../base/media'; import { MEDIA_TYPE } from '../base/media/constants';
import { import { PARTICIPANT_JOINED, PARTICIPANT_UPDATED } from '../base/participants/actionTypes';
PARTICIPANT_JOINED, import { getLocalParticipant } from '../base/participants/functions';
PARTICIPANT_UPDATED, import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
getLocalParticipant import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks/actionTypes';
} from '../base/participants';
import { MiddlewareRegistry } from '../base/redux';
import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks';
import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes'; import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';
import './middleware.any'; import './middleware.any';

View File

@ -1,13 +1,13 @@
// @flow
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
import { getMultipleVideoSupportFeatureFlag } from '../base/config'; import { getMultipleVideoSupportFeatureFlag } from '../base/config/functions';
import { StateListenerRegistry, equals } from '../base/redux'; import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { isFollowMeActive } from '../follow-me'; import { equals } from '../base/redux/functions';
import { ITrack } from '../base/tracks/reducer';
import { isFollowMeActive } from '../follow-me/functions';
import { setRemoteParticipantsWithScreenShare, virtualScreenshareParticipantsUpdated } from './actions'; import { setRemoteParticipantsWithScreenShare, virtualScreenshareParticipantsUpdated } from './actions.web';
import { getAutoPinSetting, updateAutoPinnedParticipant } from './functions'; import { getAutoPinSetting, updateAutoPinnedParticipant } from './functions.web';
StateListenerRegistry.register( StateListenerRegistry.register(
/* selector */ state => state['features/base/participants'].sortedRemoteVirtualScreenshareParticipants, /* selector */ state => state['features/base/participants'].sortedRemoteVirtualScreenshareParticipants,
@ -60,7 +60,7 @@ StateListenerRegistry.register(
} }
const oldScreenSharesOrder = store.getState()['features/video-layout'].remoteScreenShares || []; const oldScreenSharesOrder = store.getState()['features/video-layout'].remoteScreenShares || [];
const knownSharingParticipantIds = tracks.reduce((acc, track) => { const knownSharingParticipantIds = tracks.reduce((acc: string[], track: ITrack) => {
if (track.mediaType === 'video' && track.videoType === 'desktop') { if (track.mediaType === 'video' && track.videoType === 'desktop') {
const skipTrack = getAutoPinSetting() === 'remote-only' && track.local; const skipTrack = getAutoPinSetting() === 'remote-only' && track.local;
@ -76,11 +76,11 @@ StateListenerRegistry.register(
// by looping through the known sharing participants and removing any // by looping through the known sharing participants and removing any
// participant IDs which are no longer sharing. // participant IDs which are no longer sharing.
const newScreenSharesOrder = oldScreenSharesOrder.filter( const newScreenSharesOrder = oldScreenSharesOrder.filter(
participantId => knownSharingParticipantIds.includes(participantId)); (participantId: string) => knownSharingParticipantIds.includes(participantId));
// Make sure all new sharing participant get added to the end of the // Make sure all new sharing participant get added to the end of the
// known screen shares. // known screen shares.
knownSharingParticipantIds.forEach(participantId => { knownSharingParticipantIds.forEach((participantId: string) => {
if (!newScreenSharesOrder.includes(participantId)) { if (!newScreenSharesOrder.includes(participantId)) {
newScreenSharesOrder.push(participantId); newScreenSharesOrder.push(participantId);
} }

View File

@ -1,6 +1,4 @@
// @flow import { IStore } from '../app/types';
import type { Dispatch } from 'redux';
import { import {
SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_LARGE_VIDEO, SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_LARGE_VIDEO,
@ -125,7 +123,7 @@ export function setPreferredVideoQuality(preferredVideoQuality: number) {
* @returns {void} * @returns {void}
*/ */
export function setVideoQuality(frameHeight: number) { export function setVideoQuality(frameHeight: number) {
return (dispatch: Dispatch<any>) => { return (dispatch: IStore['dispatch']) => {
if (frameHeight < VIDEO_QUALITY_LEVELS.LOW) { if (frameHeight < VIDEO_QUALITY_LEVELS.LOW) {
logger.error(`Invalid frame height for video quality - ${frameHeight}`); logger.error(`Invalid frame height for video quality - ${frameHeight}`);

View File

@ -29,7 +29,7 @@ export function getReceiverVideoQualityLevel(availableHeight: number, heightToLe
* @returns {Map<number, number>|undefined} - A mapping of minimal thumbnail height required for given quality level or * @returns {Map<number, number>|undefined} - A mapping of minimal thumbnail height required for given quality level or
* {@code undefined} if the map contains invalid values. * {@code undefined} if the map contains invalid values.
*/ */
export function validateMinHeightForQualityLvl(minHeightForQualityLvl) { export function validateMinHeightForQualityLvl(minHeightForQualityLvl?: { [key: number]: string; }) {
if (typeof minHeightForQualityLvl !== 'object' if (typeof minHeightForQualityLvl !== 'object'
|| Object.keys(minHeightForQualityLvl).map(lvl => Number(lvl)) || Object.keys(minHeightForQualityLvl).map(lvl => Number(lvl))
.find(lvl => lvl === null || isNaN(lvl) || lvl < 0)) { .find(lvl => lvl === null || isNaN(lvl) || lvl < 0)) {
@ -51,7 +51,7 @@ export function validateMinHeightForQualityLvl(minHeightForQualityLvl) {
for (const level of levelsSorted) { for (const level of levelsSorted) {
const configQuality = minHeightForQualityLvl[level]; const configQuality = minHeightForQualityLvl[level];
const appQuality = CFG_LVL_TO_APP_QUALITY_LVL[configQuality]; const appQuality = CFG_LVL_TO_APP_QUALITY_LVL[configQuality as keyof typeof CFG_LVL_TO_APP_QUALITY_LVL];
if (!appQuality) { if (!appQuality) {
return undefined; return undefined;

View File

@ -1,8 +1,6 @@
// @flow import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import { SET_CONFIG } from '../base/config/actionTypes';
import { CONFERENCE_JOINED } from '../base/conference'; import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { SET_CONFIG } from '../base/config';
import { MiddlewareRegistry } from '../base/redux';
import { setPreferredVideoQuality } from './actions'; import { setPreferredVideoQuality } from './actions';
import logger from './logger'; import logger from './logger';
@ -24,7 +22,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const { resolution } = getState()['features/base/config']; const { resolution } = getState()['features/base/config'];
if (typeof resolution !== 'undefined') { if (typeof resolution !== 'undefined') {
dispatch(setPreferredVideoQuality(Number.parseInt(resolution, 10))); dispatch(setPreferredVideoQuality(Number.parseInt(`${resolution}`, 10)));
logger.info(`Configured preferred receiver video frame height to: ${resolution}`); logger.info(`Configured preferred receiver video frame height to: ${resolution}`);
} }
} }

View File

@ -1,4 +1,4 @@
// @flow import { IReduxState } from '../app/types';
/** /**
* Selects the thumbnail height to the quality level mapping from the config. * Selects the thumbnail height to the quality level mapping from the config.
@ -6,6 +6,6 @@
* @param {Object} state - The redux state. * @param {Object} state - The redux state.
* @returns {Map<number,number>} * @returns {Map<number,number>}
*/ */
export function getMinHeightForQualityLvlMap(state: Object): Map<number, number> { export function getMinHeightForQualityLvlMap(state: IReduxState): Map<number, number> {
return state['features/video-quality'].minHeightForQualityLvl; return state['features/video-quality'].minHeightForQualityLvl;
} }

View File

@ -1,26 +1,30 @@
/* global APP */
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
import { _handleParticipantError } from '../base/conference'; import { IStore } from '../app/types';
import { getSourceNameSignalingFeatureFlag } from '../base/config'; import { _handleParticipantError } from '../base/conference/functions';
import { MEDIA_TYPE } from '../base/media'; import { getSourceNameSignalingFeatureFlag } from '../base/config/functions';
import { getLocalParticipant } from '../base/participants'; import { MEDIA_TYPE } from '../base/media/constants';
import { StateListenerRegistry } from '../base/redux'; import { getLocalParticipant } from '../base/participants/functions';
import { getRemoteScreenSharesSourceNames, getTrackSourceNameByMediaTypeAndParticipant } from '../base/tracks'; import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { reportError } from '../base/util'; import {
getRemoteScreenSharesSourceNames,
getTrackSourceNameByMediaTypeAndParticipant
} from '../base/tracks/functions';
import { reportError } from '../base/util/helpers';
import { import {
getActiveParticipantsIds, getActiveParticipantsIds,
getScreenshareFilmstripParticipantId, getScreenshareFilmstripParticipantId,
isTopPanelEnabled isTopPanelEnabled
// @ts-ignore
} from '../filmstrip/functions'; } from '../filmstrip/functions';
import { LAYOUTS } from '../video-layout/constants';
import { import {
LAYOUTS,
getVideoQualityForLargeVideo, getVideoQualityForLargeVideo,
getVideoQualityForResizableFilmstripThumbnails, getVideoQualityForResizableFilmstripThumbnails,
getVideoQualityForStageThumbnails, getVideoQualityForStageThumbnails,
shouldDisplayTileView shouldDisplayTileView
} from '../video-layout'; } from '../video-layout/functions';
import { getCurrentLayout, getVideoQualityForScreenSharingFilmstrip } from '../video-layout/functions.any'; import { getCurrentLayout, getVideoQualityForScreenSharingFilmstrip } from '../video-layout/functions.any';
import { import {
@ -301,7 +305,7 @@ StateListenerRegistry.register(
* @param {number} preferred - The user preferred max frame height. * @param {number} preferred - The user preferred max frame height.
* @returns {void} * @returns {void}
*/ */
function _setSenderVideoConstraint(preferred, { getState }) { function _setSenderVideoConstraint(preferred: number, { getState }: IStore) {
const state = getState(); const state = getState();
const { conference } = state['features/base/conference']; const { conference } = state['features/base/conference'];
@ -311,7 +315,7 @@ function _setSenderVideoConstraint(preferred, { getState }) {
logger.info(`Setting sender resolution to ${preferred}`); logger.info(`Setting sender resolution to ${preferred}`);
conference.setSenderVideoConstraint(preferred) conference.setSenderVideoConstraint(preferred)
.catch(error => { .catch((error: any) => {
_handleParticipantError(error); _handleParticipantError(error);
reportError(error, `Changing sender resolution to ${preferred} failed.`); reportError(error, `Changing sender resolution to ${preferred} failed.`);
}); });
@ -323,7 +327,7 @@ function _setSenderVideoConstraint(preferred, { getState }) {
* @param {*} store - The redux store. * @param {*} store - The redux store.
* @returns {void} * @returns {void}
*/ */
function _updateReceiverVideoConstraints({ getState }) { function _updateReceiverVideoConstraints({ getState }: IStore) {
const state = getState(); const state = getState();
const { conference } = state['features/base/conference']; const { conference } = state['features/base/conference'];
@ -339,7 +343,7 @@ function _updateReceiverVideoConstraints({ getState }) {
maxReceiverVideoQualityForScreenSharingFilmstrip, maxReceiverVideoQualityForScreenSharingFilmstrip,
preferredVideoQuality preferredVideoQuality
} = state['features/video-quality']; } = state['features/video-quality'];
const { participantId: largeVideoParticipantId } = state['features/large-video']; const { participantId: largeVideoParticipantId = '' } = state['features/large-video'];
const maxFrameHeightForTileView = Math.min(maxReceiverVideoQualityForTileView, preferredVideoQuality); const maxFrameHeightForTileView = Math.min(maxReceiverVideoQualityForTileView, preferredVideoQuality);
const maxFrameHeightForStageFilmstrip = Math.min(maxReceiverVideoQualityForStageFilmstrip, preferredVideoQuality); const maxFrameHeightForStageFilmstrip = Math.min(maxReceiverVideoQualityForStageFilmstrip, preferredVideoQuality);
const maxFrameHeightForVerticalFilmstrip const maxFrameHeightForVerticalFilmstrip
@ -352,20 +356,20 @@ function _updateReceiverVideoConstraints({ getState }) {
const { visibleRemoteParticipants } = state['features/filmstrip']; const { visibleRemoteParticipants } = state['features/filmstrip'];
const tracks = state['features/base/tracks']; const tracks = state['features/base/tracks'];
const sourceNameSignaling = getSourceNameSignalingFeatureFlag(state); const sourceNameSignaling = getSourceNameSignalingFeatureFlag(state);
const localParticipantId = getLocalParticipant(state).id; const localParticipantId = getLocalParticipant(state)?.id;
const activeParticipantsIds = getActiveParticipantsIds(state); const activeParticipantsIds = getActiveParticipantsIds(state);
const screenshareFilmstripParticipantId = isTopPanelEnabled(state) && getScreenshareFilmstripParticipantId(state); const screenshareFilmstripParticipantId = isTopPanelEnabled(state) && getScreenshareFilmstripParticipantId(state);
const receiverConstraints = { const receiverConstraints: any = {
constraints: {}, constraints: {},
defaultConstraints: { 'maxHeight': VIDEO_QUALITY_LEVELS.NONE }, defaultConstraints: { 'maxHeight': VIDEO_QUALITY_LEVELS.NONE },
lastN lastN
}; };
let remoteScreenSharesSourceNames; let remoteScreenSharesSourceNames: string[];
let visibleRemoteTrackSourceNames = []; let visibleRemoteTrackSourceNames: string[] = [];
let largeVideoSourceName; let largeVideoSourceName: string | undefined;
let activeParticipantsSources = []; let activeParticipantsSources: string[] = [];
if (sourceNameSignaling) { if (sourceNameSignaling) {
receiverConstraints.onStageSources = []; receiverConstraints.onStageSources = [];
@ -390,7 +394,7 @@ function _updateReceiverVideoConstraints({ getState }) {
} }
if (activeParticipantsIds?.length > 0) { if (activeParticipantsIds?.length > 0) {
activeParticipantsIds.forEach(participantId => { activeParticipantsIds.forEach((participantId: string) => {
let sourceName; let sourceName;
if (remoteScreenSharesSourceNames.includes(participantId)) { if (remoteScreenSharesSourceNames.includes(participantId)) {
@ -491,7 +495,7 @@ function _updateReceiverVideoConstraints({ getState }) {
try { try {
conference.setReceiverConstraints(receiverConstraints); conference.setReceiverConstraints(receiverConstraints);
} catch (error) { } catch (error: any) {
_handleParticipantError(error); _handleParticipantError(error);
reportError(error, `Failed to set receiver video constraints ${JSON.stringify(receiverConstraints)}`); reportError(error, `Failed to set receiver video constraints ${JSON.stringify(receiverConstraints)}`);
} }