diff --git a/react/features/app/types.ts b/react/features/app/types.ts index cc1c17495e..e004fcdcf2 100644 --- a/react/features/app/types.ts +++ b/react/features/app/types.ts @@ -54,7 +54,21 @@ import { IPollsState } from '../polls/reducer'; import { IPowerMonitorState } from '../power-monitor/reducer'; import { IPrejoinState } from '../prejoin/reducer'; import { IReactionsState } from '../reactions/reducer'; +import { IRecentListState } from '../recent-list/reducer'; +import { IRecordingState } from '../recording/reducer'; +import { IRemoteControlState } from '../remote-control/reducer'; +import { IScreenShareState } from '../screen-share/reducer'; +import { IScreenshotCaptureState } from '../screenshot-capture/reducer'; import { ISharedVideoState } from '../shared-video/reducer'; +import { ISpeakerStatsState } from '../speaker-stats/reducer'; +import { ISubtitlesState } from '../subtitles/reducer'; +import { ITalkWhileMutedState } from '../talk-while-muted/reducer'; +import { IToolboxState } from '../toolbox/reducer'; +import { ITranscribingState } from '../transcribing/reducer'; +import { IVideoLayoutState } from '../video-layout/reducer'; +import { IVideoQualityPersistedState, IVideoQualityState } from '../video-quality/reducer'; +import { IVideoSipGW } from '../videosipgw/reducer'; +import { IVirtualBackground } from '../virtual-background/reducer'; export interface IStore { dispatch: Function, @@ -120,6 +134,22 @@ export interface IState { 'features/power-monitor': IPowerMonitorState, 'features/prejoin': IPrejoinState, 'features/reactions': IReactionsState, + 'features/recent-list': IRecentListState, + 'features/recording': IRecordingState, + 'features/remote-control': IRemoteControlState, + 'features/screen-share': IScreenShareState, + 'features/screenshot-capture': IScreenshotCaptureState, + 'features/settings': ISettingsState, 'features/shared-video': ISharedVideoState, - 'features/testing': ITestingState + 'features/speaker-stats': ISpeakerStatsState, + 'features/subtitles': ISubtitlesState, + 'features/talk-while-muted': ITalkWhileMutedState, + 'features/testing': ITestingState, + 'features/toolbox': IToolboxState, + 'features/transcribing': ITranscribingState, + 'features/video-layout': IVideoLayoutState, + 'features/video-quality': IVideoQualityState, + 'features/video-quality-persistent-storage': IVideoQualityPersistedState, + 'features/videosipgw': IVideoSipGW, + 'features/virtual-background': IVirtualBackground } diff --git a/react/features/base/connection/utils.js b/react/features/base/connection/utils.ts similarity index 99% rename from react/features/base/connection/utils.js rename to react/features/base/connection/utils.ts index addb00c987..dbaae079c7 100644 --- a/react/features/base/connection/utils.js +++ b/react/features/base/connection/utils.ts @@ -1,5 +1,3 @@ -/* @flow */ - /** * Gets a {@link URL} without hash and query/search params from a specific * {@code URL}. diff --git a/react/features/recent-list/reducer.js b/react/features/recent-list/reducer.ts similarity index 77% rename from react/features/recent-list/reducer.js rename to react/features/recent-list/reducer.ts index 6dd92f94b8..786eb39305 100644 --- a/react/features/recent-list/reducer.js +++ b/react/features/recent-list/reducer.ts @@ -1,19 +1,30 @@ -import { getURLWithoutParamsNormalized } from '../base/connection'; -import { PersistenceRegistry, ReducerRegistry } from '../base/redux'; +/* eslint-disable lines-around-comment */ +import { getURLWithoutParamsNormalized } from '../base/connection/utils'; +import PersistenceRegistry from '../base/redux/PersistenceRegistry'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { _STORE_CURRENT_CONFERENCE, _UPDATE_CONFERENCE_DURATION, DELETE_RECENT_LIST_ENTRY } from './actionTypes'; +// @ts-ignore import { isRecentListEnabled } from './functions'; +interface IRecent { + conference: string; + date: number; + duration: number; +} + +export type IRecentListState = IRecent[]; + /** * The default/initial redux state of the feature {@code recent-list}. * - * @type {Array} + * @type {IRecentListState} */ -const DEFAULT_STATE = []; +const DEFAULT_STATE: IRecentListState = []; /** * The max size of the list. @@ -35,7 +46,7 @@ PersistenceRegistry.register(STORE_NAME); /** * Reduces redux actions for the purposes of the feature {@code recent-list}. */ -ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state: IRecentListState = DEFAULT_STATE, action) => { if (isRecentListEnabled()) { switch (action.type) { case DELETE_RECENT_LIST_ENTRY: @@ -55,12 +66,12 @@ ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { /** * Deletes a recent list entry based on the url and date of the item. * - * @param {Array} state - The Redux state. + * @param {IRecentListState} state - The Redux state. * @param {Object} entryId - The ID object of the entry. - * @returns {Array} + * @returns {IRecentListState} */ function _deleteRecentListEntry( - state: Array, entryId: Object): Array { + state: Array, entryId: { date: number; url: string; }): Array { return state.filter(entry => entry.conference !== entryId.url || entry.date !== entryId.date); } @@ -68,11 +79,11 @@ function _deleteRecentListEntry( /** * Adds a new list entry to the redux store. * - * @param {Object} state - The redux state of the feature {@code recent-list}. + * @param {IRecentListState} state - The redux state of the feature {@code recent-list}. * @param {Object} action - The redux action. * @returns {Object} */ -function _storeCurrentConference(state, { locationURL }) { +function _storeCurrentConference(state: IRecentListState, { locationURL }: { locationURL: { href: string } }) { const conference = locationURL.href; // If the current conference is already in the list, we remove it to re-add @@ -96,11 +107,11 @@ function _storeCurrentConference(state, { locationURL }) { /** * Updates the conference length when left. * - * @param {Object} state - The redux state of the feature {@code recent-list}. + * @param {IRecentListState} state - The redux state of the feature {@code recent-list}. * @param {Object} action - The redux action. * @returns {Object} The next redux state of the feature {@code recent-list}. */ -function _updateConferenceDuration(state, { locationURL }) { +function _updateConferenceDuration(state: IRecentListState, { locationURL }: { locationURL: { href: string } }) { if (locationURL && locationURL.href && state.length) { const mostRecentIndex = state.length - 1; const mostRecent = state[mostRecentIndex]; diff --git a/react/features/recording/reducer.js b/react/features/recording/reducer.ts similarity index 81% rename from react/features/recording/reducer.js rename to react/features/recording/reducer.ts index 99bc4f5357..9ea5e001dc 100644 --- a/react/features/recording/reducer.js +++ b/react/features/recording/reducer.ts @@ -1,4 +1,4 @@ -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { CLEAR_RECORDING_SESSIONS, @@ -16,6 +16,27 @@ const DEFAULT_STATE = { sessionDatas: [] }; +interface SessionData { + error?: Error; + id?: string; + initiator?: Object; + liveStreamViewURL?: string; + mode?: string; + status?: string; + terminator?: Object; + timestamp?: number; +} + +export interface IRecordingState { + disableHighlightMeetingMoment: boolean; + pendingNotificationUids: { + [key: string]: number|undefined; + }; + selectedRecordingService: string; + sessionDatas: Array; + streamKey?: string; +} + /** * The name of the Redux store this feature stores its state in. */ @@ -25,7 +46,7 @@ const STORE_NAME = 'features/recording'; * Reduces the Redux actions of the feature features/recording. */ ReducerRegistry.register(STORE_NAME, - (state = DEFAULT_STATE, action) => { + (state: IRecordingState = DEFAULT_STATE, action) => { switch (action.type) { case CLEAR_RECORDING_SESSIONS: @@ -86,7 +107,7 @@ ReducerRegistry.register(STORE_NAME, * @private * @returns {Array} The session datas with the updated session data added. */ -function _updateSessionDatas(sessionDatas, newSessionData) { +function _updateSessionDatas(sessionDatas: SessionData[], newSessionData: SessionData) { const hasExistingSessionData = sessionDatas.find( sessionData => sessionData.id === newSessionData.id); let newSessionDatas; diff --git a/react/features/remote-control/reducer.js b/react/features/remote-control/reducer.ts similarity index 78% rename from react/features/remote-control/reducer.js rename to react/features/remote-control/reducer.ts index cd48e62a35..28140de443 100644 --- a/react/features/remote-control/reducer.js +++ b/react/features/remote-control/reducer.ts @@ -1,4 +1,5 @@ -import { ReducerRegistry, set } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; +import { set } from '../base/redux/functions'; import { CAPTURE_EVENTS, @@ -23,11 +24,25 @@ const DEFAULT_STATE = { } }; +export interface IRemoteControlState { + active: boolean; + controller: { + controlled?: string; + isCapturingEvents: boolean; + requestedParticipant?: string; + }; + receiver: { + controller?: string; + enabled: boolean; + transport?: Object; + } +} + /** * Listen for actions that mutate the remote control state. */ ReducerRegistry.register( - 'features/remote-control', (state = DEFAULT_STATE, action) => { + 'features/remote-control', (state: IRemoteControlState = DEFAULT_STATE, action) => { switch (action.type) { case CAPTURE_EVENTS: return { diff --git a/react/features/screen-share/reducer.js b/react/features/screen-share/reducer.ts similarity index 71% rename from react/features/screen-share/reducer.js rename to react/features/screen-share/reducer.ts index 401b602ad8..144f6a2d2b 100644 --- a/react/features/screen-share/reducer.js +++ b/react/features/screen-share/reducer.ts @@ -1,5 +1,5 @@ -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { SET_SCREEN_AUDIO_SHARE_STATE, @@ -7,10 +7,16 @@ import { SET_SCREENSHARE_TRACKS } from './actionTypes'; +export interface IScreenShareState { + captureFrameRate?: number; + desktopAudioTrack?: Object; + isSharingAudio?: boolean; +} + /** * Reduces the Redux actions of the feature features/screen-share. */ -ReducerRegistry.register('features/screen-share', (state = {}, action) => { +ReducerRegistry.register('features/screen-share', (state: IScreenShareState = {}, action) => { const { captureFrameRate, isSharingAudio, desktopAudioTrack } = action; switch (action.type) { diff --git a/react/features/screenshot-capture/reducer.js b/react/features/screenshot-capture/reducer.ts similarity index 55% rename from react/features/screenshot-capture/reducer.js rename to react/features/screenshot-capture/reducer.ts index cb408f891d..2775521fe6 100644 --- a/react/features/screenshot-capture/reducer.js +++ b/react/features/screenshot-capture/reducer.ts @@ -1,6 +1,5 @@ -// @flow - -import { PersistenceRegistry, ReducerRegistry } from '../base/redux'; +import PersistenceRegistry from '../base/redux/PersistenceRegistry'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { SET_SCREENSHOT_CAPTURE } from './actionTypes'; @@ -12,7 +11,11 @@ const DEFAULT_STATE = { capturesEnabled: false }; -ReducerRegistry.register('features/screenshot-capture', (state = DEFAULT_STATE, action) => { +export interface IScreenshotCaptureState { + capturesEnabled: boolean; +} + +ReducerRegistry.register('features/screenshot-capture', (state: IScreenshotCaptureState = DEFAULT_STATE, action) => { switch (action.type) { case SET_SCREENSHOT_CAPTURE: { return { diff --git a/react/features/settings/reducer.js b/react/features/settings/reducer.ts similarity index 62% rename from react/features/settings/reducer.js rename to react/features/settings/reducer.ts index fd5769c22f..cd973db8d8 100644 --- a/react/features/settings/reducer.js +++ b/react/features/settings/reducer.ts @@ -1,13 +1,16 @@ -// @flow - -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { SET_AUDIO_SETTINGS_VISIBILITY, SET_VIDEO_SETTINGS_VISIBILITY } from './actionTypes'; -ReducerRegistry.register('features/settings', (state = {}, action) => { +export interface ISettingsState { + audioSettingsVisible?: boolean; + videoSettingsVisible?: boolean; +} + +ReducerRegistry.register('features/settings', (state: ISettingsState = {}, action) => { switch (action.type) { case SET_AUDIO_SETTINGS_VISIBILITY: return { diff --git a/react/features/speaker-stats/reducer.js b/react/features/speaker-stats/reducer.ts similarity index 84% rename from react/features/speaker-stats/reducer.js rename to react/features/speaker-stats/reducer.ts index a98fd1851a..3f47e220f4 100644 --- a/react/features/speaker-stats/reducer.js +++ b/react/features/speaker-stats/reducer.ts @@ -1,8 +1,6 @@ -// @flow - import _ from 'lodash'; -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { INIT_SEARCH, @@ -25,7 +23,15 @@ const INITIAL_STATE = { showFaceExpressions: false }; -ReducerRegistry.register('features/speaker-stats', (state = _getInitialState(), action) => { +export interface ISpeakerStatsState { + criteria: string|null; + isOpen: boolean; + pendingReorder: boolean; + showFaceExpressions: boolean; + stats: Object; +} + +ReducerRegistry.register('features/speaker-stats', (state: ISpeakerStatsState = INITIAL_STATE, action) => { switch (action.type) { case INIT_SEARCH: return _updateCriteria(state, action); @@ -46,15 +52,6 @@ ReducerRegistry.register('features/speaker-stats', (state = _getInitialState(), return state; }); -/** - * Gets the initial state of the feature speaker-stats. - * - * @returns {Object} - */ -function _getInitialState() { - return INITIAL_STATE; -} - /** * Reduces a specific Redux action INIT_SEARCH of the feature * speaker-stats. @@ -64,7 +61,7 @@ function _getInitialState() { * @private * @returns {Object} The new state after the reduction of the specified action. */ -function _updateCriteria(state, { criteria }) { +function _updateCriteria(state: ISpeakerStatsState, { criteria }: { criteria: string|null }) { return _.assign( {}, state, @@ -86,7 +83,7 @@ function _updateCriteria(state, { criteria }) { * @private * @returns {Object} - The new state after the reduction of the specified action. */ -function _updateStats(state, { stats }) { +function _updateStats(state: ISpeakerStatsState, { stats }: { stats: any }) { const finalStats = state.pendingReorder ? stats : state.stats; if (!state.pendingReorder) { @@ -122,7 +119,7 @@ function _updateStats(state, { stats }) { * @private * @returns {Object} The new state after the reduction of the specified action. */ -function _initReorderStats(state) { +function _initReorderStats(state: ISpeakerStatsState) { return _.assign( {}, state, diff --git a/react/features/subtitles/reducer.js b/react/features/subtitles/reducer.ts similarity index 80% rename from react/features/subtitles/reducer.js rename to react/features/subtitles/reducer.ts index dc97dc3021..693da5637e 100644 --- a/react/features/subtitles/reducer.js +++ b/react/features/subtitles/reducer.ts @@ -1,4 +1,4 @@ -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { REMOVE_TRANSCRIPT_MESSAGE, @@ -14,12 +14,18 @@ const defaultState = { _language: 'transcribing.subtitlesOff' }; +export interface ISubtitlesState { + _language: string; + _requestingSubtitles: boolean; + _transcriptMessages: Map; +} + /** * Listen for actions for the transcription feature to be used by the actions * to update the rendered transcription subtitles. */ ReducerRegistry.register('features/subtitles', ( - state = defaultState, action) => { + state: ISubtitlesState = defaultState, action) => { switch (action.type) { case REMOVE_TRANSCRIPT_MESSAGE: return _removeTranscriptMessage(state, action); @@ -49,7 +55,7 @@ ReducerRegistry.register('features/subtitles', ( * @returns {Object} The new state of the feature transcription after the * reduction of the specified action. */ -function _removeTranscriptMessage(state, { transcriptMessageID }) { +function _removeTranscriptMessage(state: ISubtitlesState, { transcriptMessageID }: { transcriptMessageID: string }) { const newTranscriptMessages = new Map(state._transcriptMessages); // Deletes the key from Map once a final message arrives. @@ -70,8 +76,8 @@ function _removeTranscriptMessage(state, { transcriptMessageID }) { * @returns {Object} The new state of the feature transcription after the * reduction of the specified action. */ -function _updateTranscriptMessage(state, - { transcriptMessageID, newTranscriptMessage }) { +function _updateTranscriptMessage(state: ISubtitlesState, { transcriptMessageID, newTranscriptMessage }: + { newTranscriptMessage: Object, transcriptMessageID: string }) { const newTranscriptMessages = new Map(state._transcriptMessages); // Updates the new message for the given key in the Map. diff --git a/react/features/talk-while-muted/reducer.js b/react/features/talk-while-muted/reducer.ts similarity index 50% rename from react/features/talk-while-muted/reducer.js rename to react/features/talk-while-muted/reducer.ts index 27e532538f..538d65d2f5 100644 --- a/react/features/talk-while-muted/reducer.js +++ b/react/features/talk-while-muted/reducer.ts @@ -1,13 +1,16 @@ -// @flow - -import { ReducerRegistry, set } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; +import { set } from '../base/redux/functions'; import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes'; +export interface ITalkWhileMutedState { + currentNotificationUid?: number; +} + /** * Reduces the redux actions of the feature talk while muted. */ -ReducerRegistry.register('features/talk-while-muted', (state = { }, action) => { +ReducerRegistry.register('features/talk-while-muted', (state: ITalkWhileMutedState = { }, action) => { switch (action.type) { case SET_CURRENT_NOTIFICATION_UID: return set(state, 'currentNotificationUid', action.uid); diff --git a/react/features/toolbox/reducer.js b/react/features/toolbox/reducer.ts similarity index 87% rename from react/features/toolbox/reducer.js rename to react/features/toolbox/reducer.ts index 6f280166f0..f59298f00c 100644 --- a/react/features/toolbox/reducer.js +++ b/react/features/toolbox/reducer.ts @@ -1,6 +1,5 @@ -// @flow - -import { ReducerRegistry, set } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; +import { set } from '../base/redux/functions'; import { CLEAR_TOOLBOX_TIMEOUT, @@ -73,9 +72,20 @@ const INITIAL_STATE = { visible: false }; +export interface IToolboxState { + enabled: boolean; + fullScreen?: boolean; + hangupMenuVisible: boolean; + hovered: boolean; + overflowDrawer: boolean; + overflowMenuVisible: boolean; + timeoutID?: number|null; + visible: boolean; +} + ReducerRegistry.register( 'features/toolbox', - (state: Object = INITIAL_STATE, action: Object) => { + (state: IToolboxState = INITIAL_STATE, action): IToolboxState => { switch (action.type) { case CLEAR_TOOLBOX_TIMEOUT: return { diff --git a/react/features/transcribing/reducer.js b/react/features/transcribing/reducer.ts similarity index 86% rename from react/features/transcribing/reducer.js rename to react/features/transcribing/reducer.ts index 126e51bbd7..883cb3cf29 100644 --- a/react/features/transcribing/reducer.js +++ b/react/features/transcribing/reducer.ts @@ -1,5 +1,4 @@ - -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { _TRANSCRIBER_JOINED, @@ -59,11 +58,20 @@ function _getInitialState() { }; } +export interface ITranscribingState { + isDialing: boolean; + isTerminating: boolean; + isTranscribing: boolean; + pendingNotificationUid?: number; + potentialTranscriberJIDs: string[]; + transcriberJID?: string|null; +} + /** * Reduces the Redux actions of the feature features/transcribing. */ ReducerRegistry.register('features/transcribing', - (state = _getInitialState(), action) => { + (state: ITranscribingState = _getInitialState(), action): ITranscribingState => { switch (action.type) { case _TRANSCRIBER_JOINED: return { diff --git a/react/features/video-layout/reducer.js b/react/features/video-layout/reducer.ts similarity index 80% rename from react/features/video-layout/reducer.js rename to react/features/video-layout/reducer.ts index 324e2bc28e..9f34e42fc5 100644 --- a/react/features/video-layout/reducer.js +++ b/react/features/video-layout/reducer.ts @@ -1,6 +1,4 @@ -// @flow - -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED, @@ -33,9 +31,15 @@ const DEFAULT_STATE = { tileViewEnabled: undefined }; +export interface IVideoLayoutState { + carMode: boolean; + remoteScreenShares: string[]; + tileViewEnabled?: boolean; +} + const STORE_NAME = 'features/video-layout'; -ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state: IVideoLayoutState = DEFAULT_STATE, action): IVideoLayoutState => { switch (action.type) { case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED: case VIRTUAL_SCREENSHARE_REMOTE_PARTICIPANTS_UPDATED: diff --git a/react/features/video-quality/constants.js b/react/features/video-quality/constants.ts similarity index 100% rename from react/features/video-quality/constants.js rename to react/features/video-quality/constants.ts diff --git a/react/features/video-quality/logger.js b/react/features/video-quality/logger.ts similarity index 91% rename from react/features/video-quality/logger.js rename to react/features/video-quality/logger.ts index d19b7aee85..ed5840c4e3 100644 --- a/react/features/video-quality/logger.js +++ b/react/features/video-quality/logger.ts @@ -1,5 +1,3 @@ -// @flow - import { getLogger } from '../base/logging/functions'; export default getLogger('features/video-quality'); diff --git a/react/features/video-quality/reducer.js b/react/features/video-quality/reducer.ts similarity index 71% rename from react/features/video-quality/reducer.js rename to react/features/video-quality/reducer.ts index 5abd3d7769..23fb65b08e 100644 --- a/react/features/video-quality/reducer.js +++ b/react/features/video-quality/reducer.ts @@ -1,8 +1,13 @@ -import { SET_CONFIG } from '../base/config'; -import { PersistenceRegistry, ReducerRegistry, set } from '../base/redux'; +import { SET_CONFIG } from '../base/config/actionTypes'; +import { IConfig } from '../base/config/configType'; +import PersistenceRegistry from '../base/redux/PersistenceRegistry'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; +import { set } from '../base/redux/functions'; import { SET_MAX_RECEIVER_VIDEO_QUALITY, SET_PREFERRED_VIDEO_QUALITY } from './actionTypes'; import { VIDEO_QUALITY_LEVELS } from './constants'; +/* eslint-disable-next-line lines-around-comment */ +// @ts-ignore import { validateMinHeightForQualityLvl } from './functions'; import logger from './logger'; @@ -15,12 +20,23 @@ const DEFAULT_STATE = { DEFAULT_STATE.minHeightForQualityLvl.set(360, VIDEO_QUALITY_LEVELS.STANDARD); DEFAULT_STATE.minHeightForQualityLvl.set(720, VIDEO_QUALITY_LEVELS.HIGH); +export interface IVideoQualityState { + maxReceiverVideoQuality: number; + minHeightForQualityLvl: Map; + preferredVideoQuality: number; +} + +export interface IVideoQualityPersistedState { + persistedPrefferedVideoQuality?: number; +} + // When the persisted state is initialized the current state (for example the default state) is erased. // In order to workaround this issue we need additional state for the persisted properties. PersistenceRegistry.register('features/video-quality-persistent-storage'); -ReducerRegistry.register('features/video-quality-persistent-storage', (state = {}, action) => { +ReducerRegistry.register('features/video-quality-persistent-storage', +(state: IVideoQualityPersistedState = {}, action): IVideoQualityPersistedState => { switch (action.type) { case SET_PREFERRED_VIDEO_QUALITY: { const { preferredVideoQuality } = action; @@ -35,7 +51,8 @@ ReducerRegistry.register('features/video-quality-persistent-storage', (state = { return state; }); -ReducerRegistry.register('features/video-quality', (state = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/video-quality', +(state: IVideoQualityState = DEFAULT_STATE, action): IVideoQualityState => { switch (action.type) { case SET_CONFIG: return _setConfig(state, action); @@ -65,7 +82,7 @@ ReducerRegistry.register('features/video-quality', (state = DEFAULT_STATE, actio * @private * @returns {Object} The new state after the reduction of the specified action. */ -function _setConfig(state, { config }) { +function _setConfig(state: IVideoQualityState, { config }: { config: IConfig }) { const configuredMap = config?.videoQuality?.minHeightForQualityLvl; const convertedMap = validateMinHeightForQualityLvl(configuredMap); diff --git a/react/features/videosipgw/reducer.js b/react/features/videosipgw/reducer.ts similarity index 61% rename from react/features/videosipgw/reducer.js rename to react/features/videosipgw/reducer.ts index 9f3606fd16..d60653c363 100644 --- a/react/features/videosipgw/reducer.js +++ b/react/features/videosipgw/reducer.ts @@ -1,9 +1,13 @@ -import { ReducerRegistry } from '../base/redux'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { SIP_GW_AVAILABILITY_CHANGED } from './actionTypes'; +export interface IVideoSipGW { + status?: string; +} + ReducerRegistry.register( - 'features/videosipgw', (state = [], action) => { + 'features/videosipgw', (state: IVideoSipGW = {}, action): IVideoSipGW => { switch (action.type) { case SIP_GW_AVAILABILITY_CHANGED: { return { diff --git a/react/features/virtual-background/reducer.js b/react/features/virtual-background/reducer.ts similarity index 76% rename from react/features/virtual-background/reducer.js rename to react/features/virtual-background/reducer.ts index 5b4a89d7b9..4c1e7a22b2 100644 --- a/react/features/virtual-background/reducer.js +++ b/react/features/virtual-background/reducer.ts @@ -1,12 +1,19 @@ -// @flow - -import { PersistenceRegistry, ReducerRegistry } from '../base/redux'; +import PersistenceRegistry from '../base/redux/PersistenceRegistry'; +import ReducerRegistry from '../base/redux/ReducerRegistry'; import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes'; import { VIRTUAL_BACKGROUND_TYPE } from './constants'; const STORE_NAME = 'features/virtual-background'; +export interface IVirtualBackground { + backgroundEffectEnabled?: boolean; + backgroundType?: string; + blurValue?: number; + selectedThumbnail?: string; + virtualSource?: string; +} + /** * Reduces redux actions which activate/deactivate virtual background image, or * indicate if the virtual image background is activated/deactivated. The @@ -18,7 +25,7 @@ const STORE_NAME = 'features/virtual-background'; * @returns {State} The next redux state that is the result of reducing the * specified action. */ -ReducerRegistry.register(STORE_NAME, (state = {}, action) => { +ReducerRegistry.register(STORE_NAME, (state: IVirtualBackground = {}, action): IVirtualBackground => { const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action; /**