From 271ea8315b422d1c1db1c29b05905f3327d803bc Mon Sep 17 00:00:00 2001 From: Robert Pintilii Date: Mon, 5 Sep 2022 12:05:07 +0300 Subject: [PATCH] ref: Improve reducers TS (#12123) --- react/features/analytics/reducer.ts | 3 ++- react/features/app/types.ts | 11 +++++---- react/features/authentication/reducer.ts | 3 ++- react/features/av-moderation/reducer.ts | 4 ++-- react/features/base/app/reducer.ts | 2 +- react/features/base/audio-only/reducer.ts | 3 ++- react/features/base/conference/reducer.ts | 23 ++++++++---------- react/features/base/config/reducer.ts | 12 ++++++---- react/features/base/connection/reducer.ts | 11 ++++----- .../base/devices/{logger.js => logger.ts} | 2 -- react/features/base/devices/reducer.ts | 9 +++---- react/features/base/dialog/reducer.ts | 2 +- react/features/base/flags/reducer.ts | 2 +- react/features/base/jwt/reducer.ts | 4 ++-- react/features/base/known-domains/reducer.ts | 6 +++-- react/features/base/lastn/reducer.ts | 2 +- react/features/base/lib-jitsi-meet/reducer.ts | 4 ++-- react/features/base/logging/reducer.ts | 4 ++-- react/features/base/media/reducer.ts | 2 +- react/features/base/net-info/reducer.ts | 2 +- react/features/base/participants/functions.ts | 2 +- react/features/base/participants/reducer.ts | 3 ++- react/features/base/redux/ReducerRegistry.ts | 2 +- react/features/base/responsive-ui/reducer.ts | 3 ++- react/features/base/settings/reducer.ts | 2 +- react/features/base/sounds/reducer.ts | 4 ++-- react/features/base/testing/reducer.ts | 4 ++-- react/features/base/tracks/reducer.ts | 4 ++-- .../features/base/user-interaction/reducer.ts | 3 ++- react/features/breakout-rooms/reducer.ts | 2 +- react/features/calendar-sync/reducer.tsx | 2 +- react/features/chat/reducer.ts | 2 +- react/features/deep-linking/reducer.ts | 2 +- react/features/dropbox/reducer.ts | 2 +- react/features/dynamic-branding/reducer.ts | 2 +- react/features/e2ee/reducer.ts | 2 +- react/features/etherpad/reducer.ts | 4 ++-- react/features/face-landmarks/reducer.ts | 3 ++- react/features/feedback/reducer.ts | 4 ++-- react/features/filmstrip/reducer.ts | 4 ++-- react/features/follow-me/reducer.ts | 4 ++-- react/features/gifs/reducer.ts | 6 ++--- react/features/google-api/reducer.ts | 4 ++-- react/features/invite/reducer.ts | 2 +- react/features/jaas/reducer.ts | 4 ++-- react/features/large-video/reducer.ts | 4 +++- react/features/lobby/reducer.ts | 2 +- react/features/mobile/audio-mode/reducer.ts | 3 ++- react/features/mobile/background/reducer.ts | 2 +- .../mobile/call-integration/reducer.js | 16 ------------- .../mobile/call-integration/reducer.ts | 24 +++++++++++++++++++ react/features/mobile/external-api/reducer.ts | 3 ++- react/features/mobile/full-screen/reducer.ts | 2 +- react/features/mobile/watchos/reducer.ts | 3 ++- react/features/no-audio-signal/reducer.ts | 2 +- react/features/noise-detection/reducer.ts | 3 ++- react/features/noise-suppression/reducer.ts | 3 ++- react/features/notifications/reducer.ts | 4 ++-- react/features/overlay/reducer.ts | 2 +- react/features/polls/reducer.ts | 2 +- react/features/power-monitor/reducer.ts | 2 +- react/features/prejoin/reducer.ts | 4 ++-- react/features/reactions/middleware.ts | 2 +- react/features/reactions/reducer.ts | 10 ++++---- react/features/recent-list/reducer.ts | 2 +- react/features/recording/reducer.ts | 4 ++-- react/features/remote-control/reducer.ts | 4 ++-- .../room-lock/{constants.js => constants.ts} | 0 react/features/screen-share/reducer.ts | 2 +- react/features/screenshot-capture/reducer.ts | 3 ++- react/features/shared-video/reducer.ts | 4 ++-- react/features/speaker-stats/reducer.ts | 3 ++- react/features/subtitles/reducer.ts | 4 ++-- react/features/talk-while-muted/reducer.ts | 3 ++- react/features/toolbox/reducer.ts | 4 ++-- react/features/transcribing/reducer.ts | 4 ++-- react/features/video-layout/reducer.ts | 2 +- react/features/video-quality/reducer.ts | 8 +++---- react/features/videosipgw/reducer.ts | 4 ++-- react/features/virtual-background/reducer.ts | 2 +- 80 files changed, 177 insertions(+), 156 deletions(-) rename react/features/base/devices/{logger.js => logger.ts} (91%) delete mode 100644 react/features/mobile/call-integration/reducer.js create mode 100644 react/features/mobile/call-integration/reducer.ts rename react/features/room-lock/{constants.js => constants.ts} (100%) diff --git a/react/features/analytics/reducer.ts b/react/features/analytics/reducer.ts index 185f06a06..e77a26c50 100644 --- a/react/features/analytics/reducer.ts +++ b/react/features/analytics/reducer.ts @@ -52,7 +52,8 @@ export interface IAnalyticsState { * @param {string} action.type - Type of action. * @returns {Object} */ -ReducerRegistry.register('features/analytics', (state: IAnalyticsState = DEFAULT_STATE, action: any) => { +ReducerRegistry.register('features/analytics', +(state = DEFAULT_STATE, action): IAnalyticsState => { switch (action.type) { case UPDATE_LOCAL_TRACKS_DURATION: return { diff --git a/react/features/app/types.ts b/react/features/app/types.ts index e004fcdcf..4ad499fc3 100644 --- a/react/features/app/types.ts +++ b/react/features/app/types.ts @@ -4,12 +4,13 @@ import { IAVModerationState } from '../av-moderation/reducer'; import { IAppState } from '../base/app/reducer'; import { IAudioOnlyState } from '../base/audio-only/reducer'; import { IConferenceState } from '../base/conference/reducer'; -import { IConfig } from '../base/config/configType'; +import { IConfigState } from '../base/config/reducer'; import { IConnectionState } from '../base/connection/reducer'; import { IDevicesState } from '../base/devices/reducer'; import { IDialogState } from '../base/dialog/reducer'; import { IFlagsState } from '../base/flags/reducer'; import { IJwtState } from '../base/jwt/reducer'; +import { IKnownDomainsState } from '../base/known-domains/reducer'; import { ILastNState } from '../base/lastn/reducer'; import { ILibJitsiMeetState } from '../base/lib-jitsi-meet/reducer'; import { ILoggingState } from '../base/logging/reducer'; @@ -42,6 +43,7 @@ import { ILargeVideoState } from '../large-video/reducer'; import { ILobbyState } from '../lobby/reducer'; import { IMobileAudioModeState } from '../mobile/audio-mode/reducer'; import { IBackgroundState } from '../mobile/background/reducer'; +import { ICallIntegrationState } from '../mobile/call-integration/reducer'; import { IMobileExternalApiState } from '../mobile/external-api/reducer'; import { IFullScreenState } from '../mobile/full-screen/reducer'; import { IMobileWatchOSState } from '../mobile/watchos/reducer'; @@ -72,7 +74,7 @@ import { IVirtualBackground } from '../virtual-background/reducer'; export interface IStore { dispatch: Function, - getState: Function + getState: () => IState; } export interface IState { @@ -83,13 +85,13 @@ export interface IState { 'features/base/app': IAppState, 'features/base/audio-only': IAudioOnlyState, 'features/base/conference': IConferenceState, - 'features/base/config': IConfig, + 'features/base/config': IConfigState, 'features/base/connection': IConnectionState, 'features/base/devices': IDevicesState, 'features/base/dialog': IDialogState, 'features/base/flags': IFlagsState, 'features/base/jwt': IJwtState, - 'features/base/known-domains': Array, + 'features/base/known-domains': IKnownDomainsState, 'features/base/lastn': ILastNState, 'features/base/lib-jitsi-meet': ILibJitsiMeetState, 'features/base/logging': ILoggingState, @@ -104,6 +106,7 @@ export interface IState { 'features/base/user-interaction': IUserInteractionState, 'features/breakout-rooms': IBreakoutRoomsState, 'features/calendar-sync': ICalendarSyncState, + 'features/call-integration': ICallIntegrationState, 'features/chat': IChatState, 'features/deep-linking': IDeepLinkingState, 'features/dropbox': IDropboxState, diff --git a/react/features/authentication/reducer.ts b/react/features/authentication/reducer.ts index c7c4c2c5e..58e45ef51 100644 --- a/react/features/authentication/reducer.ts +++ b/react/features/authentication/reducer.ts @@ -24,7 +24,8 @@ export interface IAuthenticationState { * @param {string} action.type - Type of action. * @returns {Object} */ -ReducerRegistry.register('features/authentication', (state: IAuthenticationState = {}, action: any) => { +ReducerRegistry.register('features/authentication', +(state = {}, action): IAuthenticationState => { switch (action.type) { case CANCEL_LOGIN: return assign(state, { diff --git a/react/features/av-moderation/reducer.ts b/react/features/av-moderation/reducer.ts index d8c9b6207..f5d573e7c 100644 --- a/react/features/av-moderation/reducer.ts +++ b/react/features/av-moderation/reducer.ts @@ -73,8 +73,8 @@ function _updatePendingParticipant(mediaType: MediaType, participant: any, state return false; } -ReducerRegistry.register('features/av-moderation', (state: IAVModerationState = initialState, action: any) => { - +ReducerRegistry.register('features/av-moderation', +(state = initialState, action): IAVModerationState => { switch (action.type) { case DISABLE_MODERATION: { const newState = action.mediaType === MEDIA_TYPE.AUDIO diff --git a/react/features/base/app/reducer.ts b/react/features/base/app/reducer.ts index 0b656bc23..baea437e0 100644 --- a/react/features/base/app/reducer.ts +++ b/react/features/base/app/reducer.ts @@ -6,7 +6,7 @@ export interface IAppState { app?: Object|undefined; } -ReducerRegistry.register('features/base/app', (state: IAppState = {}, action) => { +ReducerRegistry.register('features/base/app', (state = {}, action): IAppState => { switch (action.type) { case APP_WILL_MOUNT: { const { app } = action; diff --git a/react/features/base/audio-only/reducer.ts b/react/features/base/audio-only/reducer.ts index f24dca3f5..93d1351ea 100644 --- a/react/features/base/audio-only/reducer.ts +++ b/react/features/base/audio-only/reducer.ts @@ -11,7 +11,8 @@ const DEFAULT_STATE = { }; -ReducerRegistry.register('features/base/audio-only', (state: IAudioOnlyState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/base/audio-only', +(state = DEFAULT_STATE, action): IAudioOnlyState => { switch (action.type) { case SET_AUDIO_ONLY: return { diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.ts index 091da229e..3d113f315 100644 --- a/react/features/base/conference/reducer.ts +++ b/react/features/base/conference/reducer.ts @@ -1,15 +1,10 @@ -/* eslint-disable import/order */ -// @ts-ignore -import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../room-lock'; - -// @ts-ignore -import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection'; - +/* eslint-disable lines-around-comment */ +import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../room-lock/constants'; +import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection/actionTypes'; // @ts-ignore import { JitsiConferenceErrors } from '../lib-jitsi-meet'; - -import { assign, set } from '../redux/functions'; import ReducerRegistry from '../redux/ReducerRegistry'; +import { assign, set } from '../redux/functions'; import { AUTH_STATUS_CHANGED, @@ -31,7 +26,6 @@ import { SET_START_MUTED_POLICY, SET_START_REACTIONS_MUTED } from './actionTypes'; - // @ts-ignore import { isRoomValid } from './functions'; @@ -59,11 +53,15 @@ export interface IConferenceState { localSubject?: string; locked: string|undefined; membersOnly: boolean|undefined; + obfuscatedRoom?: string; + obfuscatedRoomSource?: string; password: string|undefined; passwordRequired: boolean|undefined; pendingSubjectChange?: string; room?: Object; + startAudioMutedPolicy?: boolean; startReactionsMuted?: boolean; + startVideoMutedPolicy?: boolean; subject?: string; } @@ -71,9 +69,8 @@ export interface IConferenceState { * Listen for actions that contain the conference object, so that it can be * stored for use by other action creators. */ -ReducerRegistry.register( - 'features/base/conference', - (state: IConferenceState = DEFAULT_STATE, action: any) => { +ReducerRegistry.register('features/base/conference', + (state = DEFAULT_STATE, action): IConferenceState => { switch (action.type) { case AUTH_STATUS_CHANGED: return _authStatusChanged(state, action); diff --git a/react/features/base/config/reducer.ts b/react/features/base/config/reducer.ts index 87969d2fb..55b15ac09 100644 --- a/react/features/base/config/reducer.ts +++ b/react/features/base/config/reducer.ts @@ -1,10 +1,8 @@ -/* eslint-disable import/order */ import _ from 'lodash'; import { CONFERENCE_INFO } from '../../conference/components/constants'; - -import { equals } from '../redux/functions'; import ReducerRegistry from '../redux/ReducerRegistry'; +import { equals } from '../redux/functions'; import { UPDATE_CONFIG, @@ -14,7 +12,7 @@ import { OVERWRITE_CONFIG } from './actionTypes'; import { IConfig } from './configType'; - +// eslint-disable-next-line lines-around-comment // @ts-ignore import { _cleanupConfig } from './functions'; @@ -72,7 +70,11 @@ const CONFERENCE_HEADER_MAPPING: any = { hideRecordingLabel: [ 'recording' ] }; -ReducerRegistry.register('features/base/config', (state: IConfig = _getInitialState(), action: any) => { +export interface IConfigState extends IConfig { + error?: Error; +} + +ReducerRegistry.register('features/base/config', (state = _getInitialState(), action): IConfigState => { switch (action.type) { case UPDATE_CONFIG: return _updateConfig(state, action); diff --git a/react/features/base/connection/reducer.ts b/react/features/base/connection/reducer.ts index 84a47fdd9..8e207e234 100644 --- a/react/features/base/connection/reducer.ts +++ b/react/features/base/connection/reducer.ts @@ -1,11 +1,9 @@ -/* eslint-disable import/order */ - +/* eslint-disable lines-around-comment */ import { SET_ROOM } from '../conference/actionTypes'; - // @ts-ignore import { JitsiConnectionErrors } from '../lib-jitsi-meet'; -import { assign, set } from '../redux/functions'; import ReducerRegistry from '../redux/ReducerRegistry'; +import { assign, set } from '../redux/functions'; import { CONNECTION_DISCONNECTED, @@ -15,7 +13,6 @@ import { SET_LOCATION_URL, SHOW_CONNECTION_INFO } from './actionTypes'; - // @ts-ignore import { ConnectionFailedError } from './actions.native'; @@ -32,9 +29,9 @@ export interface IConnectionState { /** * Reduces the Redux actions of the feature base/connection. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/connection', - (state: IConnectionState = {}, action: any) => { + (state = {}, action): IConnectionState => { switch (action.type) { case CONNECTION_DISCONNECTED: return _connectionDisconnected(state, action); diff --git a/react/features/base/devices/logger.js b/react/features/base/devices/logger.ts similarity index 91% rename from react/features/base/devices/logger.js rename to react/features/base/devices/logger.ts index 8a99c13de..1a2cc0a34 100644 --- a/react/features/base/devices/logger.js +++ b/react/features/base/devices/logger.ts @@ -1,5 +1,3 @@ -// @flow - import { getLogger } from '../logging/functions'; export default getLogger('features/base/devices'); diff --git a/react/features/base/devices/reducer.ts b/react/features/base/devices/reducer.ts index ab5bd5c0f..7737c2718 100644 --- a/react/features/base/devices/reducer.ts +++ b/react/features/base/devices/reducer.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/order */ import ReducerRegistry from '../redux/ReducerRegistry'; import { @@ -9,11 +8,9 @@ import { SET_VIDEO_INPUT_DEVICE, UPDATE_DEVICE_LIST } from './actionTypes'; - +// eslint-disable-next-line lines-around-comment // @ts-ignore import { groupDevicesByKind } from './functions'; - -// @ts-ignore import logger from './logger'; @@ -53,9 +50,9 @@ export interface IDevicesState { * video devices. * @returns {Object} */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/devices', - (state: IDevicesState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): IDevicesState => { switch (action.type) { case UPDATE_DEVICE_LIST: { const deviceList = groupDevicesByKind(action.devices); diff --git a/react/features/base/dialog/reducer.ts b/react/features/base/dialog/reducer.ts index 75897d5e0..92cf32a9b 100644 --- a/react/features/base/dialog/reducer.ts +++ b/react/features/base/dialog/reducer.ts @@ -24,7 +24,7 @@ export interface IDialogState { * @returns {State} The next redux state that is the result of reducing the * specified action. */ -ReducerRegistry.register('features/base/dialog', (state: IDialogState = {}, action) => { +ReducerRegistry.register('features/base/dialog', (state = {}, action): IDialogState => { switch (action.type) { case HIDE_DIALOG: { const { component } = action; diff --git a/react/features/base/flags/reducer.ts b/react/features/base/flags/reducer.ts index c683dd827..3bb10f416 100644 --- a/react/features/base/flags/reducer.ts +++ b/react/features/base/flags/reducer.ts @@ -22,7 +22,7 @@ export interface IFlagsState { * @returns {State} The next redux state that is the result of reducing the * specified action. */ -ReducerRegistry.register('features/base/flags', (state: IFlagsState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/base/flags', (state = DEFAULT_STATE, action): IFlagsState => { switch (action.type) { case UPDATE_FLAGS: { const newState = _.merge({}, state, action.flags); diff --git a/react/features/base/jwt/reducer.ts b/react/features/base/jwt/reducer.ts index 3d1eb2a42..ad48db98a 100644 --- a/react/features/base/jwt/reducer.ts +++ b/react/features/base/jwt/reducer.ts @@ -16,9 +16,9 @@ export interface IJwtState { * @returns {Object} The next redux state which is the result of reducing the * specified {@code action}. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/jwt', - (state: IJwtState = {}, action) => { + (state = {}, action): IJwtState => { switch (action.type) { case SET_JWT: { // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/react/features/base/known-domains/reducer.ts b/react/features/base/known-domains/reducer.ts index cdc2dd17f..23caec95f 100644 --- a/react/features/base/known-domains/reducer.ts +++ b/react/features/base/known-domains/reducer.ts @@ -24,7 +24,9 @@ const STORE_NAME = 'features/base/known-domains'; PersistenceRegistry.register(STORE_NAME); -ReducerRegistry.register(STORE_NAME, (state: Array = DEFAULT_STATE, action) => { +export type IKnownDomainsState = Array; + +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): IKnownDomainsState => { switch (action.type) { case ADD_KNOWN_DOMAINS: return _addKnownDomains(state, action.knownDomains); @@ -43,7 +45,7 @@ ReducerRegistry.register(STORE_NAME, (state: Array = DEFAULT_STATE, acti * @private * @returns {Object} The next redux state. */ -function _addKnownDomains(state: Array, knownDomains: Array) { +function _addKnownDomains(state: IKnownDomainsState, knownDomains: Array) { // In case persistence has deserialized a weird redux state: let nextState = Array.isArray(state) ? state : []; diff --git a/react/features/base/lastn/reducer.ts b/react/features/base/lastn/reducer.ts index 28ccdeb7c..f39d55389 100644 --- a/react/features/base/lastn/reducer.ts +++ b/react/features/base/lastn/reducer.ts @@ -17,7 +17,7 @@ export interface ILastNState { }; } -ReducerRegistry.register('features/base/lastn', (state: ILastNState = { }, action) => { +ReducerRegistry.register('features/base/lastn', (state = {}, action): ILastNState => { switch (action.type) { case SET_CONFIG: return _setConfig(state, action); diff --git a/react/features/base/lib-jitsi-meet/reducer.ts b/react/features/base/lib-jitsi-meet/reducer.ts index a9645d8e7..cc0ea9342 100644 --- a/react/features/base/lib-jitsi-meet/reducer.ts +++ b/react/features/base/lib-jitsi-meet/reducer.ts @@ -18,9 +18,9 @@ export interface ILibJitsiMeetState { initialized?: boolean; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/lib-jitsi-meet', - (state: ILibJitsiMeetState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): ILibJitsiMeetState => { switch (action.type) { case LIB_DID_DISPOSE: return DEFAULT_STATE; diff --git a/react/features/base/logging/reducer.ts b/react/features/base/logging/reducer.ts index 060c1ebda..acb89e5e0 100644 --- a/react/features/base/logging/reducer.ts +++ b/react/features/base/logging/reducer.ts @@ -65,9 +65,9 @@ export interface ILoggingState { logCollector?: Object; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/logging', - (state: ILoggingState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): ILoggingState => { switch (action.type) { case SET_LOGGING_CONFIG: return _setLoggingConfig(state, action); diff --git a/react/features/base/media/reducer.ts b/react/features/base/media/reducer.ts index 65951f717..5a11373c0 100644 --- a/react/features/base/media/reducer.ts +++ b/react/features/base/media/reducer.ts @@ -252,7 +252,7 @@ export interface IMediaState { * modified. * @returns {Object} */ -ReducerRegistry.register('features/base/media', combineReducers({ +ReducerRegistry.register('features/base/media', combineReducers({ audio: _audio, screenshare: _screenshare, video: _video diff --git a/react/features/base/net-info/reducer.ts b/react/features/base/net-info/reducer.ts index 0a78d4c67..72b7c409f 100644 --- a/react/features/base/net-info/reducer.ts +++ b/react/features/base/net-info/reducer.ts @@ -21,7 +21,7 @@ export interface INetInfoState { /** * The base/net-info feature's reducer. */ -ReducerRegistry.register(STORE_NAME, (state: INetInfoState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): INetInfoState => { switch (action.type) { case SET_NETWORK_INFO: return assign(state, { diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.ts index 9a8729d6c..40db0866d 100644 --- a/react/features/base/participants/functions.ts +++ b/react/features/base/participants/functions.ts @@ -256,7 +256,7 @@ export function getParticipantByIdOrUndefined(stateful: IStore | Function, parti * features/base/participants. * @returns {number} */ -export function getParticipantCount(stateful: IStore | Function) { +export function getParticipantCount(stateful: IStore | Function | IState) { const state = toState(stateful); const { local, diff --git a/react/features/base/participants/reducer.ts b/react/features/base/participants/reducer.ts index 2064da6e2..51453a304 100644 --- a/react/features/base/participants/reducer.ts +++ b/react/features/base/participants/reducer.ts @@ -140,7 +140,8 @@ export interface IParticipantsState { * added/removed/modified. * @returns {Participant[]} */ -ReducerRegistry.register('features/base/participants', (state: IParticipantsState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/base/participants', +(state = DEFAULT_STATE, action): IParticipantsState => { switch (action.type) { case PARTICIPANT_ID_CHANGED: { const { local } = state; diff --git a/react/features/base/redux/ReducerRegistry.ts b/react/features/base/redux/ReducerRegistry.ts index 08fa08b3a..900b212ce 100644 --- a/react/features/base/redux/ReducerRegistry.ts +++ b/react/features/base/redux/ReducerRegistry.ts @@ -52,7 +52,7 @@ class ReducerRegistry { * @param {Reducer} reducer - A Redux reducer. * @returns {void} */ - register(name: string, reducer: Reducer) { + register(name: string, reducer: Reducer) { this._elements[name] = reducer; } } diff --git a/react/features/base/responsive-ui/reducer.ts b/react/features/base/responsive-ui/reducer.ts index 92649082d..4433b83fc 100644 --- a/react/features/base/responsive-ui/reducer.ts +++ b/react/features/base/responsive-ui/reducer.ts @@ -40,7 +40,8 @@ export interface IResponsiveUIState { } } -ReducerRegistry.register('features/base/responsive-ui', (state: IResponsiveUIState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/base/responsive-ui', +(state = DEFAULT_STATE, action): IResponsiveUIState => { switch (action.type) { case CLIENT_RESIZED: { return { diff --git a/react/features/base/settings/reducer.ts b/react/features/base/settings/reducer.ts index 43e8c4775..1df001f3d 100644 --- a/react/features/base/settings/reducer.ts +++ b/react/features/base/settings/reducer.ts @@ -108,7 +108,7 @@ filterSubtree.micDeviceId = false; PersistenceRegistry.register(STORE_NAME, filterSubtree, DEFAULT_STATE); -ReducerRegistry.register(STORE_NAME, (state: ISettingsState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): ISettingsState => { switch (action.type) { case APP_WILL_MOUNT: return _initSettings(state); diff --git a/react/features/base/sounds/reducer.ts b/react/features/base/sounds/reducer.ts index f1968f54d..ffd452d32 100644 --- a/react/features/base/sounds/reducer.ts +++ b/react/features/base/sounds/reducer.ts @@ -51,9 +51,9 @@ export type ISoundsState = Map; /** * The base/sounds feature's reducer. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/base/sounds', - (state: ISoundsState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): ISoundsState => { switch (action.type) { case _ADD_AUDIO_ELEMENT: case _REMOVE_AUDIO_ELEMENT: diff --git a/react/features/base/testing/reducer.ts b/react/features/base/testing/reducer.ts index 38bf06860..eb7ac3e64 100644 --- a/react/features/base/testing/reducer.ts +++ b/react/features/base/testing/reducer.ts @@ -18,9 +18,9 @@ export interface ITestingState { connectionState: string; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/testing', - (state: ITestingState = INITIAL_STATE, action) => { + (state = INITIAL_STATE, action): ITestingState => { switch (action.type) { case SET_CONNECTION_STATE: return _setConnectionState(state, action); diff --git a/react/features/base/tracks/reducer.ts b/react/features/base/tracks/reducer.ts index 6a38a14ab..81a203e48 100644 --- a/react/features/base/tracks/reducer.ts +++ b/react/features/base/tracks/reducer.ts @@ -136,7 +136,7 @@ export type ITracksState = ITrack[]; /** * Listen for actions that mutate (e.g. Add, remove) local and remote tracks. */ -ReducerRegistry.register('features/base/tracks', (state: ITracksState = [], action) => { +ReducerRegistry.register('features/base/tracks', (state = [], action): ITracksState => { switch (action.type) { case PARTICIPANT_ID_CHANGED: case TRACK_NO_DATA_FROM_SOURCE: @@ -179,7 +179,7 @@ export interface INoSrcDataState { /** * Listen for actions that mutate the no-src-data state, like the current notification id. */ -ReducerRegistry.register('features/base/no-src-data', (state: INoSrcDataState = {}, action) => { +ReducerRegistry.register('features/base/no-src-data', (state = {}, action): INoSrcDataState => { switch (action.type) { case SET_NO_SRC_DATA_NOTIFICATION_UID: return set(state, 'noSrcDataNotificationUid', action.uid); diff --git a/react/features/base/user-interaction/reducer.ts b/react/features/base/user-interaction/reducer.ts index 54c8f28f6..bf0bcca26 100644 --- a/react/features/base/user-interaction/reducer.ts +++ b/react/features/base/user-interaction/reducer.ts @@ -8,7 +8,8 @@ export interface IUserInteractionState { } -ReducerRegistry.register('features/base/user-interaction', (state: IUserInteractionState = {}, action) => { +ReducerRegistry.register('features/base/user-interaction', +(state = {}, action): IUserInteractionState => { switch (action.type) { case APP_WILL_MOUNT: case APP_WILL_UNMOUNT: diff --git a/react/features/breakout-rooms/reducer.ts b/react/features/breakout-rooms/reducer.ts index f08cab01c..c2308dd28 100644 --- a/react/features/breakout-rooms/reducer.ts +++ b/react/features/breakout-rooms/reducer.ts @@ -34,7 +34,7 @@ export interface IBreakoutRoomsState { /** * Listen for actions for the breakout-rooms feature. */ -ReducerRegistry.register(FEATURE_KEY, (state: IBreakoutRoomsState = DEFAULT_STATE, action: any) => { +ReducerRegistry.register(FEATURE_KEY, (state = DEFAULT_STATE, action): IBreakoutRoomsState => { switch (action.type) { case _UPDATE_ROOM_COUNTER: return { diff --git a/react/features/calendar-sync/reducer.tsx b/react/features/calendar-sync/reducer.tsx index dfbf4b174..73ed217ad 100644 --- a/react/features/calendar-sync/reducer.tsx +++ b/react/features/calendar-sync/reducer.tsx @@ -58,7 +58,7 @@ PersistenceRegistry.register(STORE_NAME, { msAuthState: true }); -ReducerRegistry.register(STORE_NAME, (state: ICalendarSyncState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): ICalendarSyncState => { switch (action.type) { case CLEAR_CALENDAR_INTEGRATION: return DEFAULT_STATE; diff --git a/react/features/chat/reducer.ts b/react/features/chat/reducer.ts index 31fbf14d5..a6e3b2d21 100644 --- a/react/features/chat/reducer.ts +++ b/react/features/chat/reducer.ts @@ -55,7 +55,7 @@ export interface IChatState { privateMessageRecipient?: Participant; } -ReducerRegistry.register('features/chat', (state: IChatState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/chat', (state = DEFAULT_STATE, action): IChatState => { switch (action.type) { case ADD_MESSAGE: { const newMessage: IMessage = { diff --git a/react/features/deep-linking/reducer.ts b/react/features/deep-linking/reducer.ts index c44319cf0..b88ebac08 100644 --- a/react/features/deep-linking/reducer.ts +++ b/react/features/deep-linking/reducer.ts @@ -6,7 +6,7 @@ export interface IDeepLinkingState { launchInWeb?: boolean; } -ReducerRegistry.register('features/deep-linking', (state = {}, action) => { +ReducerRegistry.register('features/deep-linking', (state = {}, action): IDeepLinkingState => { switch (action.type) { case OPEN_WEB_APP: { return { diff --git a/react/features/dropbox/reducer.ts b/react/features/dropbox/reducer.ts index dcc504e3d..2a5e020b0 100644 --- a/react/features/dropbox/reducer.ts +++ b/react/features/dropbox/reducer.ts @@ -19,7 +19,7 @@ export interface IDropboxState { */ PersistenceRegistry.register(STORE_NAME); -ReducerRegistry.register(STORE_NAME, (state: IDropboxState = {}, action) => { +ReducerRegistry.register(STORE_NAME, (state = {}, action): IDropboxState => { switch (action.type) { case UPDATE_DROPBOX_TOKEN: return { diff --git a/react/features/dynamic-branding/reducer.ts b/react/features/dynamic-branding/reducer.ts index 95a04b499..894d09c56 100644 --- a/react/features/dynamic-branding/reducer.ts +++ b/react/features/dynamic-branding/reducer.ts @@ -163,7 +163,7 @@ export interface IDynamicBrandingState { /** * Reduces redux actions for the purposes of the feature {@code dynamic-branding}. */ -ReducerRegistry.register(STORE_NAME, (state: IDynamicBrandingState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): IDynamicBrandingState => { switch (action.type) { case SET_DYNAMIC_BRANDING_DATA: { const { diff --git a/react/features/e2ee/reducer.ts b/react/features/e2ee/reducer.ts index d31377675..7f193920f 100644 --- a/react/features/e2ee/reducer.ts +++ b/react/features/e2ee/reducer.ts @@ -23,7 +23,7 @@ export interface IE2EEState { /** * Reduces the Redux actions of the feature features/e2ee. */ -ReducerRegistry.register('features/e2ee', (state: IE2EEState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/e2ee', (state = DEFAULT_STATE, action): IE2EEState => { switch (action.type) { case TOGGLE_E2EE: return { diff --git a/react/features/etherpad/reducer.ts b/react/features/etherpad/reducer.ts index 12406ee30..b1181adee 100644 --- a/react/features/etherpad/reducer.ts +++ b/react/features/etherpad/reducer.ts @@ -26,9 +26,9 @@ export interface IEtherpadState { /** * Reduces the Redux actions of the feature features/etherpad. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/etherpad', - (state: IEtherpadState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): IEtherpadState => { switch (action.type) { case SET_DOCUMENT_EDITING_STATUS: return { diff --git a/react/features/face-landmarks/reducer.ts b/react/features/face-landmarks/reducer.ts index d9c7ae2c2..657377ab3 100644 --- a/react/features/face-landmarks/reducer.ts +++ b/react/features/face-landmarks/reducer.ts @@ -46,7 +46,8 @@ export interface IFaceLandmarksState { recognitionActive: boolean; } -ReducerRegistry.register('features/face-landmarks', (state: IFaceLandmarksState = defaultState, action) => { +ReducerRegistry.register('features/face-landmarks', +(state = defaultState, action): IFaceLandmarksState => { switch (action.type) { case ADD_FACE_EXPRESSION: { return { diff --git a/react/features/feedback/reducer.ts b/react/features/feedback/reducer.ts index cd674837e..9eab8cc4f 100644 --- a/react/features/feedback/reducer.ts +++ b/react/features/feedback/reducer.ts @@ -24,9 +24,9 @@ export interface IFeedbackState { /** * Reduces the Redux actions of the feature features/feedback. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/feedback', - (state: IFeedbackState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): IFeedbackState => { switch (action.type) { case CANCEL_FEEDBACK: { return { diff --git a/react/features/filmstrip/reducer.ts b/react/features/filmstrip/reducer.ts index 0bcf689be..5faa88832 100644 --- a/react/features/filmstrip/reducer.ts +++ b/react/features/filmstrip/reducer.ts @@ -258,9 +258,9 @@ export interface IFilmstripState { } } -ReducerRegistry.register( +ReducerRegistry.register( 'features/filmstrip', - (state: IFilmstripState = DEFAULT_STATE, action) => { + (state = DEFAULT_STATE, action): IFilmstripState => { switch (action.type) { case SET_FILMSTRIP_ENABLED: return { diff --git a/react/features/follow-me/reducer.ts b/react/features/follow-me/reducer.ts index aa9e84211..82c83f3df 100644 --- a/react/features/follow-me/reducer.ts +++ b/react/features/follow-me/reducer.ts @@ -16,9 +16,9 @@ export interface IFollowMeState { /** * Listen for actions that contain the Follow Me feature active state, so that it can be stored. */ -ReducerRegistry.register( +ReducerRegistry.register( 'features/follow-me', - (state: IFollowMeState = {}, action) => { + (state = {}, action): IFollowMeState => { switch (action.type) { case SET_FOLLOW_ME_MODERATOR: { diff --git a/react/features/gifs/reducer.ts b/react/features/gifs/reducer.ts index 5dcaa0453..5e94effff 100644 --- a/react/features/gifs/reducer.ts +++ b/react/features/gifs/reducer.ts @@ -23,9 +23,9 @@ export interface IGifsState { menuOpen: boolean; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/gifs', - (state = initialState, action) => { + (state = initialState, action): IGifsState => { switch (action.type) { case ADD_GIF_FOR_PARTICIPANT: { const newList = state.gifList; @@ -55,7 +55,7 @@ ReducerRegistry.register( const gif = state.gifList.get(action.participantId); newList.set(action.participantId, { - gifUrl: gif.gifUrl, + gifUrl: gif?.gifUrl ?? '', timeoutID: action.timeoutID }); diff --git a/react/features/google-api/reducer.ts b/react/features/google-api/reducer.ts index 53a023659..0bdca234a 100644 --- a/react/features/google-api/reducer.ts +++ b/react/features/google-api/reducer.ts @@ -25,8 +25,8 @@ export interface IGoogleApiState { /** * Reduces the Redux actions of the feature features/google-api. */ -ReducerRegistry.register('features/google-api', - (state: IGoogleApiState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/google-api', + (state = DEFAULT_STATE, action): IGoogleApiState => { switch (action.type) { case SET_GOOGLE_API_STATE: return { diff --git a/react/features/invite/reducer.ts b/react/features/invite/reducer.ts index 2efc4080e..3bd929c6c 100644 --- a/react/features/invite/reducer.ts +++ b/react/features/invite/reducer.ts @@ -37,7 +37,7 @@ export interface IInviteState { sipUri?: string; } -ReducerRegistry.register('features/invite', (state: IInviteState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action): IInviteState => { switch (action.type) { case ADD_PENDING_INVITE_REQUEST: return { diff --git a/react/features/jaas/reducer.ts b/react/features/jaas/reducer.ts index af82206b8..486aee20b 100644 --- a/react/features/jaas/reducer.ts +++ b/react/features/jaas/reducer.ts @@ -17,8 +17,8 @@ export interface IJaaSState { /** * Listen for actions that mutate the billing-counter state. */ -ReducerRegistry.register( - 'features/jaas', (state: IJaaSState = DEFAULT_STATE, action) => { +ReducerRegistry.register( + 'features/jaas', (state = DEFAULT_STATE, action): IJaaSState => { switch (action.type) { case SET_DETAILS: { diff --git a/react/features/large-video/reducer.ts b/react/features/large-video/reducer.ts index 811d82010..c70635d82 100644 --- a/react/features/large-video/reducer.ts +++ b/react/features/large-video/reducer.ts @@ -10,13 +10,15 @@ import { } from './actionTypes'; export interface ILargeVideoState { + height?: number; lastMediaEvent?: string; participantId?: string; resolution?: number; seeWhatIsBeingShared?: boolean; + width?: number; } -ReducerRegistry.register('features/large-video', (state: ILargeVideoState = {}, action) => { +ReducerRegistry.register('features/large-video', (state = {}, action): ILargeVideoState => { switch (action.type) { // When conference is joined, we update ID of local participant from default diff --git a/react/features/lobby/reducer.ts b/react/features/lobby/reducer.ts index ac4fad521..b9af2974d 100644 --- a/react/features/lobby/reducer.ts +++ b/react/features/lobby/reducer.ts @@ -42,7 +42,7 @@ export interface ILobbyState { * @returns {Object} The next redux state which is the result of reducing the * specified {@code action}. */ -ReducerRegistry.register('features/lobby', (state: ILobbyState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/lobby', (state = DEFAULT_STATE, action): ILobbyState => { switch (action.type) { case CONFERENCE_JOINED: case CONFERENCE_LEFT: diff --git a/react/features/mobile/audio-mode/reducer.ts b/react/features/mobile/audio-mode/reducer.ts index a8245f18d..36998bfb0 100644 --- a/react/features/mobile/audio-mode/reducer.ts +++ b/react/features/mobile/audio-mode/reducer.ts @@ -13,7 +13,8 @@ const DEFAULT_STATE = { subscriptions: [] }; -ReducerRegistry.register('features/mobile/audio-mode', (state: IMobileAudioModeState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/mobile/audio-mode', +(state = DEFAULT_STATE, action): IMobileAudioModeState => { switch (action.type) { case _SET_AUDIOMODE_DEVICES: { const { devices } = action; diff --git a/react/features/mobile/background/reducer.ts b/react/features/mobile/background/reducer.ts index 380cb927d..684de0647 100644 --- a/react/features/mobile/background/reducer.ts +++ b/react/features/mobile/background/reducer.ts @@ -17,7 +17,7 @@ const DEFAULT_STATE = { appState: 'active' }; -ReducerRegistry.register('features/background', (state: IBackgroundState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/background', (state = DEFAULT_STATE, action): IBackgroundState => { switch (action.type) { case _SET_APP_STATE_LISTENER: return { diff --git a/react/features/mobile/call-integration/reducer.js b/react/features/mobile/call-integration/reducer.js deleted file mode 100644 index 5a87e3c1a..000000000 --- a/react/features/mobile/call-integration/reducer.js +++ /dev/null @@ -1,16 +0,0 @@ -import { assign, ReducerRegistry } from '../../base/redux'; - -import CallKit from './CallKit'; -import ConnectionService from './ConnectionService'; -import { _SET_CALL_INTEGRATION_SUBSCRIPTIONS } from './actionTypes'; - -(CallKit || ConnectionService) && ReducerRegistry.register( - 'features/call-integration', - (state = {}, action) => { - switch (action.type) { - case _SET_CALL_INTEGRATION_SUBSCRIPTIONS: - return assign(state, 'subscriptions', action.subscriptions); - } - - return state; - }); diff --git a/react/features/mobile/call-integration/reducer.ts b/react/features/mobile/call-integration/reducer.ts new file mode 100644 index 000000000..b8c87a82e --- /dev/null +++ b/react/features/mobile/call-integration/reducer.ts @@ -0,0 +1,24 @@ +/* eslint-disable lines-around-comment */ +import ReducerRegistry from '../../base/redux/ReducerRegistry'; +import { set } from '../../base/redux/functions'; + +// @ts-ignore +import CallKit from './CallKit'; +// @ts-ignore +import ConnectionService from './ConnectionService'; +import { _SET_CALL_INTEGRATION_SUBSCRIPTIONS } from './actionTypes'; + +export interface ICallIntegrationState { + subscriptions?: any; +} + +(CallKit || ConnectionService) && ReducerRegistry.register( + 'features/call-integration', + (state = {}, action): ICallIntegrationState => { + switch (action.type) { + case _SET_CALL_INTEGRATION_SUBSCRIPTIONS: + return set(state, 'subscriptions', action.subscriptions); + } + + return state; + }); diff --git a/react/features/mobile/external-api/reducer.ts b/react/features/mobile/external-api/reducer.ts index 374eb69a8..11e1e774c 100644 --- a/react/features/mobile/external-api/reducer.ts +++ b/react/features/mobile/external-api/reducer.ts @@ -10,7 +10,8 @@ const DEFAULT_STATE = { screenShares: [] }; -ReducerRegistry.register('features/mobile/external-api', (state: IMobileExternalApiState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/mobile/external-api', +(state = DEFAULT_STATE, action): IMobileExternalApiState => { switch (action.type) { case SCREEN_SHARE_PARTICIPANTS_UPDATED: { return { diff --git a/react/features/mobile/full-screen/reducer.ts b/react/features/mobile/full-screen/reducer.ts index 8ea949264..d86eb0ad8 100644 --- a/react/features/mobile/full-screen/reducer.ts +++ b/react/features/mobile/full-screen/reducer.ts @@ -6,7 +6,7 @@ export interface IFullScreenState { listener?: Function; } -ReducerRegistry.register('features/full-screen', (state: IFullScreenState = {}, action) => { +ReducerRegistry.register('features/full-screen', (state = {}, action): IFullScreenState => { switch (action.type) { case _SET_IMMERSIVE_LISTENER: return { diff --git a/react/features/mobile/watchos/reducer.ts b/react/features/mobile/watchos/reducer.ts index 020e318a2..a83265213 100644 --- a/react/features/mobile/watchos/reducer.ts +++ b/react/features/mobile/watchos/reducer.ts @@ -16,7 +16,8 @@ const INITIAL_STATE = { /** * Reduces the Redux actions of the feature features/mobile/watchos. */ -ReducerRegistry.register('features/mobile/watchos', (state: IMobileWatchOSState = INITIAL_STATE, action) => { +ReducerRegistry.register('features/mobile/watchos', +(state = INITIAL_STATE, action): IMobileWatchOSState => { switch (action.type) { case SET_CONFERENCE_TIMESTAMP: { return assign(state, { diff --git a/react/features/no-audio-signal/reducer.ts b/react/features/no-audio-signal/reducer.ts index 2d06b0081..f6bab4996 100644 --- a/react/features/no-audio-signal/reducer.ts +++ b/react/features/no-audio-signal/reducer.ts @@ -10,7 +10,7 @@ export interface INoAudioSignalState { /** * Reduces the redux actions of the feature no audio signal. */ -ReducerRegistry.register('features/no-audio-signal', (state: INoAudioSignalState = {}, action) => { +ReducerRegistry.register('features/no-audio-signal', (state = {}, action): INoAudioSignalState => { switch (action.type) { case SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID: return set(state, 'noAudioSignalNotificationUid', action.uid); diff --git a/react/features/noise-detection/reducer.ts b/react/features/noise-detection/reducer.ts index ff1512d13..e8c29a207 100644 --- a/react/features/noise-detection/reducer.ts +++ b/react/features/noise-detection/reducer.ts @@ -10,7 +10,8 @@ export interface INoiseDetectionState { /** * Reduces the redux actions of noise detection feature. */ -ReducerRegistry.register('features/noise-detection', (state: INoiseDetectionState = {}, action) => { +ReducerRegistry.register('features/noise-detection', +(state = {}, action): INoiseDetectionState => { switch (action.type) { case SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID: return set(state, 'noisyAudioInputNotificationUid', action.uid); diff --git a/react/features/noise-suppression/reducer.ts b/react/features/noise-suppression/reducer.ts index 3119c09c3..0fd8cd1b9 100644 --- a/react/features/noise-suppression/reducer.ts +++ b/react/features/noise-suppression/reducer.ts @@ -15,7 +15,8 @@ const DEFAULT_STATE = { /** * Reduces the Redux actions of the feature features/noise-suppression. */ -ReducerRegistry.register('features/noise-suppression', (state: INoiseSuppressionState = DEFAULT_STATE, action: any) => { +ReducerRegistry.register('features/noise-suppression', +(state = DEFAULT_STATE, action): INoiseSuppressionState => { const { enabled } = action; switch (action.type) { diff --git a/react/features/notifications/reducer.ts b/react/features/notifications/reducer.ts index 7fb67c4f8..8a9ba0271 100644 --- a/react/features/notifications/reducer.ts +++ b/react/features/notifications/reducer.ts @@ -42,8 +42,8 @@ export interface INotificationsState { * @returns {Object} The next redux state which is the result of reducing the * specified {@code action}. */ -ReducerRegistry.register('features/notifications', - (state: INotificationsState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/notifications', + (state = DEFAULT_STATE, action): INotificationsState => { switch (action.type) { case CLEAR_NOTIFICATIONS: return { diff --git a/react/features/overlay/reducer.ts b/react/features/overlay/reducer.ts index 3bad8ff97..5aefa9cf7 100644 --- a/react/features/overlay/reducer.ts +++ b/react/features/overlay/reducer.ts @@ -21,7 +21,7 @@ export interface IOverlayState { * * FIXME: these pieces of state should probably be in a different place. */ -ReducerRegistry.register('features/overlay', (state: IOverlayState = { }, action) => { +ReducerRegistry.register('features/overlay', (state = {}, action): IOverlayState => { switch (action.type) { case CONFIG_WILL_LOAD: return _setShowLoadConfigOverlay(state, Boolean(action.room)); diff --git a/react/features/polls/reducer.ts b/react/features/polls/reducer.ts index 1ae76fde2..6f7b7b453 100644 --- a/react/features/polls/reducer.ts +++ b/react/features/polls/reducer.ts @@ -25,7 +25,7 @@ export interface IPollsState { }; } -ReducerRegistry.register('features/polls', (state: IPollsState = INITIAL_STATE, action) => { +ReducerRegistry.register('features/polls', (state = INITIAL_STATE, action): IPollsState => { switch (action.type) { case CHANGE_VOTE: { diff --git a/react/features/power-monitor/reducer.ts b/react/features/power-monitor/reducer.ts index abfab6671..e90a81c1c 100644 --- a/react/features/power-monitor/reducer.ts +++ b/react/features/power-monitor/reducer.ts @@ -16,7 +16,7 @@ export interface IPowerMonitorState { /** * Reduces the redux actions of the feature power monitor. */ -ReducerRegistry.register('features/power-monitor', (state: IPowerMonitorState = { }, action) => { +ReducerRegistry.register('features/power-monitor', (state = {}, action): IPowerMonitorState => { switch (action.type) { case SET_TRANSPORT: return _setTransport(state, action.transport); diff --git a/react/features/prejoin/reducer.ts b/react/features/prejoin/reducer.ts index 940a7aeaf..b59fe303c 100644 --- a/react/features/prejoin/reducer.ts +++ b/react/features/prejoin/reducer.ts @@ -65,8 +65,8 @@ PersistenceRegistry.register('features/prejoin', { /** * Listen for actions that mutate the prejoin state. */ -ReducerRegistry.register( - 'features/prejoin', (state: IPrejoinState = DEFAULT_STATE, action) => { +ReducerRegistry.register( + 'features/prejoin', (state = DEFAULT_STATE, action): IPrejoinState => { switch (action.type) { case PREJOIN_JOINING_IN_PROGRESS: return { diff --git a/react/features/reactions/middleware.ts b/react/features/reactions/middleware.ts index 01265b8fe..042cfda12 100644 --- a/react/features/reactions/middleware.ts +++ b/react/features/reactions/middleware.ts @@ -109,7 +109,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action:any) const { timeoutID, buffer } = getState()['features/reactions']; const { reaction } = action; - clearTimeout(timeoutID); + clearTimeout(timeoutID ?? 0); buffer.push(reaction); action.buffer = buffer; action.timeoutID = setTimeout(() => { diff --git a/react/features/reactions/reducer.ts b/react/features/reactions/reducer.ts index ce4c8f5f3..68b6fadc8 100644 --- a/react/features/reactions/reducer.ts +++ b/react/features/reactions/reducer.ts @@ -77,9 +77,9 @@ function _getInitialState(): IReactionsState { }; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/reactions', - (state: IReactionsState = _getInitialState(), action: ReactionsAction) => { + (state = _getInitialState(), action: ReactionsAction): IReactionsState => { switch (action.type) { case TOGGLE_REACTIONS_VISIBLE: @@ -91,8 +91,8 @@ ReducerRegistry.register( case ADD_REACTION_BUFFER: return { ...state, - buffer: action.buffer, - timeoutID: action.timeoutID + buffer: action.buffer ?? [], + timeoutID: action.timeoutID ?? null }; case FLUSH_REACTION_BUFFER: @@ -105,7 +105,7 @@ ReducerRegistry.register( case SET_REACTION_QUEUE: { return { ...state, - queue: action.queue + queue: action.queue ?? [] }; } diff --git a/react/features/recent-list/reducer.ts b/react/features/recent-list/reducer.ts index 786eb3930..5c018bf88 100644 --- a/react/features/recent-list/reducer.ts +++ b/react/features/recent-list/reducer.ts @@ -46,7 +46,7 @@ PersistenceRegistry.register(STORE_NAME); /** * Reduces redux actions for the purposes of the feature {@code recent-list}. */ -ReducerRegistry.register(STORE_NAME, (state: IRecentListState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action): IRecentListState => { if (isRecentListEnabled()) { switch (action.type) { case DELETE_RECENT_LIST_ENTRY: diff --git a/react/features/recording/reducer.ts b/react/features/recording/reducer.ts index 9ea5e001d..11a923a08 100644 --- a/react/features/recording/reducer.ts +++ b/react/features/recording/reducer.ts @@ -45,8 +45,8 @@ const STORE_NAME = 'features/recording'; /** * Reduces the Redux actions of the feature features/recording. */ -ReducerRegistry.register(STORE_NAME, - (state: IRecordingState = DEFAULT_STATE, action) => { +ReducerRegistry.register(STORE_NAME, + (state = DEFAULT_STATE, action): IRecordingState => { switch (action.type) { case CLEAR_RECORDING_SESSIONS: diff --git a/react/features/remote-control/reducer.ts b/react/features/remote-control/reducer.ts index 28140de44..128689fab 100644 --- a/react/features/remote-control/reducer.ts +++ b/react/features/remote-control/reducer.ts @@ -41,8 +41,8 @@ export interface IRemoteControlState { /** * Listen for actions that mutate the remote control state. */ -ReducerRegistry.register( - 'features/remote-control', (state: IRemoteControlState = DEFAULT_STATE, action) => { +ReducerRegistry.register( + 'features/remote-control', (state = DEFAULT_STATE, action): IRemoteControlState => { switch (action.type) { case CAPTURE_EVENTS: return { diff --git a/react/features/room-lock/constants.js b/react/features/room-lock/constants.ts similarity index 100% rename from react/features/room-lock/constants.js rename to react/features/room-lock/constants.ts diff --git a/react/features/screen-share/reducer.ts b/react/features/screen-share/reducer.ts index 144f6a2d2..5ab424d8c 100644 --- a/react/features/screen-share/reducer.ts +++ b/react/features/screen-share/reducer.ts @@ -16,7 +16,7 @@ export interface IScreenShareState { /** * Reduces the Redux actions of the feature features/screen-share. */ -ReducerRegistry.register('features/screen-share', (state: IScreenShareState = {}, action) => { +ReducerRegistry.register('features/screen-share', (state = {}, action): IScreenShareState => { const { captureFrameRate, isSharingAudio, desktopAudioTrack } = action; switch (action.type) { diff --git a/react/features/screenshot-capture/reducer.ts b/react/features/screenshot-capture/reducer.ts index 2775521fe..694dc34b6 100644 --- a/react/features/screenshot-capture/reducer.ts +++ b/react/features/screenshot-capture/reducer.ts @@ -15,7 +15,8 @@ export interface IScreenshotCaptureState { capturesEnabled: boolean; } -ReducerRegistry.register('features/screenshot-capture', (state: IScreenshotCaptureState = DEFAULT_STATE, action) => { +ReducerRegistry.register('features/screenshot-capture', +(state = DEFAULT_STATE, action): IScreenshotCaptureState => { switch (action.type) { case SET_SCREENSHOT_CAPTURE: { return { diff --git a/react/features/shared-video/reducer.ts b/react/features/shared-video/reducer.ts index 1bec55f21..641e8a98b 100644 --- a/react/features/shared-video/reducer.ts +++ b/react/features/shared-video/reducer.ts @@ -17,8 +17,8 @@ export interface ISharedVideoState { /** * Reduces the Redux actions of the feature features/shared-video. */ -ReducerRegistry.register('features/shared-video', -(state: ISharedVideoState = initialState, action): ISharedVideoState => { +ReducerRegistry.register('features/shared-video', +(state = initialState, action): ISharedVideoState => { const { videoUrl, status, time, ownerId, disabled, muted, volume } = action; switch (action.type) { diff --git a/react/features/speaker-stats/reducer.ts b/react/features/speaker-stats/reducer.ts index 3f47e220f..e41b76dc4 100644 --- a/react/features/speaker-stats/reducer.ts +++ b/react/features/speaker-stats/reducer.ts @@ -31,7 +31,8 @@ export interface ISpeakerStatsState { stats: Object; } -ReducerRegistry.register('features/speaker-stats', (state: ISpeakerStatsState = INITIAL_STATE, action) => { +ReducerRegistry.register('features/speaker-stats', +(state = INITIAL_STATE, action): ISpeakerStatsState => { switch (action.type) { case INIT_SEARCH: return _updateCriteria(state, action); diff --git a/react/features/subtitles/reducer.ts b/react/features/subtitles/reducer.ts index 693da5637..0a4fb6d2d 100644 --- a/react/features/subtitles/reducer.ts +++ b/react/features/subtitles/reducer.ts @@ -24,8 +24,8 @@ export interface ISubtitlesState { * Listen for actions for the transcription feature to be used by the actions * to update the rendered transcription subtitles. */ -ReducerRegistry.register('features/subtitles', ( - state: ISubtitlesState = defaultState, action) => { +ReducerRegistry.register('features/subtitles', ( + state = defaultState, action): ISubtitlesState => { switch (action.type) { case REMOVE_TRANSCRIPT_MESSAGE: return _removeTranscriptMessage(state, action); diff --git a/react/features/talk-while-muted/reducer.ts b/react/features/talk-while-muted/reducer.ts index 538d65d2f..9fa5eef7c 100644 --- a/react/features/talk-while-muted/reducer.ts +++ b/react/features/talk-while-muted/reducer.ts @@ -10,7 +10,8 @@ export interface ITalkWhileMutedState { /** * Reduces the redux actions of the feature talk while muted. */ -ReducerRegistry.register('features/talk-while-muted', (state: ITalkWhileMutedState = { }, action) => { +ReducerRegistry.register('features/talk-while-muted', +(state = {}, action): ITalkWhileMutedState => { switch (action.type) { case SET_CURRENT_NOTIFICATION_UID: return set(state, 'currentNotificationUid', action.uid); diff --git a/react/features/toolbox/reducer.ts b/react/features/toolbox/reducer.ts index f59298f00..8bdae3b89 100644 --- a/react/features/toolbox/reducer.ts +++ b/react/features/toolbox/reducer.ts @@ -83,9 +83,9 @@ export interface IToolboxState { visible: boolean; } -ReducerRegistry.register( +ReducerRegistry.register( 'features/toolbox', - (state: IToolboxState = INITIAL_STATE, action): IToolboxState => { + (state = INITIAL_STATE, action): IToolboxState => { switch (action.type) { case CLEAR_TOOLBOX_TIMEOUT: return { diff --git a/react/features/transcribing/reducer.ts b/react/features/transcribing/reducer.ts index 883cb3cf2..9cbcc4ec9 100644 --- a/react/features/transcribing/reducer.ts +++ b/react/features/transcribing/reducer.ts @@ -70,8 +70,8 @@ export interface ITranscribingState { /** * Reduces the Redux actions of the feature features/transcribing. */ -ReducerRegistry.register('features/transcribing', - (state: ITranscribingState = _getInitialState(), action): ITranscribingState => { +ReducerRegistry.register('features/transcribing', + (state = _getInitialState(), action): ITranscribingState => { switch (action.type) { case _TRANSCRIBER_JOINED: return { diff --git a/react/features/video-layout/reducer.ts b/react/features/video-layout/reducer.ts index 9f34e42fc..10c58680e 100644 --- a/react/features/video-layout/reducer.ts +++ b/react/features/video-layout/reducer.ts @@ -39,7 +39,7 @@ export interface IVideoLayoutState { const STORE_NAME = 'features/video-layout'; -ReducerRegistry.register(STORE_NAME, (state: IVideoLayoutState = DEFAULT_STATE, action): IVideoLayoutState => { +ReducerRegistry.register(STORE_NAME, (state = 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/reducer.ts b/react/features/video-quality/reducer.ts index 284d9185d..8855813e4 100644 --- a/react/features/video-quality/reducer.ts +++ b/react/features/video-quality/reducer.ts @@ -55,8 +55,8 @@ export interface IVideoQualityPersistedState { // 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: IVideoQualityPersistedState = {}, action): IVideoQualityPersistedState => { +ReducerRegistry.register('features/video-quality-persistent-storage', +(state = {}, action): IVideoQualityPersistedState => { switch (action.type) { case SET_PREFERRED_VIDEO_QUALITY: { const { preferredVideoQuality } = action; @@ -71,8 +71,8 @@ ReducerRegistry.register('features/video-quality-persistent-storage', return state; }); -ReducerRegistry.register('features/video-quality', -(state: IVideoQualityState = DEFAULT_STATE, action): IVideoQualityState => { +ReducerRegistry.register('features/video-quality', +(state = DEFAULT_STATE, action): IVideoQualityState => { switch (action.type) { case SET_CONFIG: return _setConfig(state, action); diff --git a/react/features/videosipgw/reducer.ts b/react/features/videosipgw/reducer.ts index d60653c36..d52bf3603 100644 --- a/react/features/videosipgw/reducer.ts +++ b/react/features/videosipgw/reducer.ts @@ -6,8 +6,8 @@ export interface IVideoSipGW { status?: string; } -ReducerRegistry.register( - 'features/videosipgw', (state: IVideoSipGW = {}, action): IVideoSipGW => { +ReducerRegistry.register( + 'features/videosipgw', (state = {}, action): IVideoSipGW => { switch (action.type) { case SIP_GW_AVAILABILITY_CHANGED: { return { diff --git a/react/features/virtual-background/reducer.ts b/react/features/virtual-background/reducer.ts index 4c1e7a22b..75609d0c2 100644 --- a/react/features/virtual-background/reducer.ts +++ b/react/features/virtual-background/reducer.ts @@ -25,7 +25,7 @@ export interface IVirtualBackground { * @returns {State} The next redux state that is the result of reducing the * specified action. */ -ReducerRegistry.register(STORE_NAME, (state: IVirtualBackground = {}, action): IVirtualBackground => { +ReducerRegistry.register(STORE_NAME, (state = {}, action): IVirtualBackground => { const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action; /**