ref: Improve reducers TS (#12123)

This commit is contained in:
Robert Pintilii 2022-09-05 12:05:07 +03:00 committed by GitHub
parent f18f8c1061
commit 271ea8315b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 177 additions and 156 deletions

View File

@ -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<IAnalyticsState>('features/analytics',
(state = DEFAULT_STATE, action): IAnalyticsState => {
switch (action.type) {
case UPDATE_LOCAL_TRACKS_DURATION:
return {

View File

@ -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<string>,
'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,

View File

@ -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<IAuthenticationState>('features/authentication',
(state = {}, action): IAuthenticationState => {
switch (action.type) {
case CANCEL_LOGIN:
return assign(state, {

View File

@ -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<IAVModerationState>('features/av-moderation',
(state = initialState, action): IAVModerationState => {
switch (action.type) {
case DISABLE_MODERATION: {
const newState = action.mediaType === MEDIA_TYPE.AUDIO

View File

@ -6,7 +6,7 @@ export interface IAppState {
app?: Object|undefined;
}
ReducerRegistry.register('features/base/app', (state: IAppState = {}, action) => {
ReducerRegistry.register<IAppState>('features/base/app', (state = {}, action): IAppState => {
switch (action.type) {
case APP_WILL_MOUNT: {
const { app } = action;

View File

@ -11,7 +11,8 @@ const DEFAULT_STATE = {
};
ReducerRegistry.register('features/base/audio-only', (state: IAudioOnlyState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IAudioOnlyState>('features/base/audio-only',
(state = DEFAULT_STATE, action): IAudioOnlyState => {
switch (action.type) {
case SET_AUDIO_ONLY:
return {

View File

@ -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<IConferenceState>('features/base/conference',
(state = DEFAULT_STATE, action): IConferenceState => {
switch (action.type) {
case AUTH_STATUS_CHANGED:
return _authStatusChanged(state, action);

View File

@ -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<IConfigState>('features/base/config', (state = _getInitialState(), action): IConfigState => {
switch (action.type) {
case UPDATE_CONFIG:
return _updateConfig(state, action);

View File

@ -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<IConnectionState>(
'features/base/connection',
(state: IConnectionState = {}, action: any) => {
(state = {}, action): IConnectionState => {
switch (action.type) {
case CONNECTION_DISCONNECTED:
return _connectionDisconnected(state, action);

View File

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

View File

@ -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<IDevicesState>(
'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);

View File

@ -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<IDialogState>('features/base/dialog', (state = {}, action): IDialogState => {
switch (action.type) {
case HIDE_DIALOG: {
const { component } = action;

View File

@ -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<IFlagsState>('features/base/flags', (state = DEFAULT_STATE, action): IFlagsState => {
switch (action.type) {
case UPDATE_FLAGS: {
const newState = _.merge({}, state, action.flags);

View File

@ -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<IJwtState>(
'features/base/jwt',
(state: IJwtState = {}, action) => {
(state = {}, action): IJwtState => {
switch (action.type) {
case SET_JWT: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars

View File

@ -24,7 +24,9 @@ const STORE_NAME = 'features/base/known-domains';
PersistenceRegistry.register(STORE_NAME);
ReducerRegistry.register(STORE_NAME, (state: Array<string> = DEFAULT_STATE, action) => {
export type IKnownDomainsState = Array<string>;
ReducerRegistry.register<IKnownDomainsState>(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<string> = DEFAULT_STATE, acti
* @private
* @returns {Object} The next redux state.
*/
function _addKnownDomains(state: Array<string>, knownDomains: Array<string>) {
function _addKnownDomains(state: IKnownDomainsState, knownDomains: Array<string>) {
// In case persistence has deserialized a weird redux state:
let nextState = Array.isArray(state) ? state : [];

View File

@ -17,7 +17,7 @@ export interface ILastNState {
};
}
ReducerRegistry.register('features/base/lastn', (state: ILastNState = { }, action) => {
ReducerRegistry.register<ILastNState>('features/base/lastn', (state = {}, action): ILastNState => {
switch (action.type) {
case SET_CONFIG:
return _setConfig(state, action);

View File

@ -18,9 +18,9 @@ export interface ILibJitsiMeetState {
initialized?: boolean;
}
ReducerRegistry.register(
ReducerRegistry.register<ILibJitsiMeetState>(
'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;

View File

@ -65,9 +65,9 @@ export interface ILoggingState {
logCollector?: Object;
}
ReducerRegistry.register(
ReducerRegistry.register<ILoggingState>(
'features/base/logging',
(state: ILoggingState = DEFAULT_STATE, action) => {
(state = DEFAULT_STATE, action): ILoggingState => {
switch (action.type) {
case SET_LOGGING_CONFIG:
return _setLoggingConfig(state, action);

View File

@ -252,7 +252,7 @@ export interface IMediaState {
* modified.
* @returns {Object}
*/
ReducerRegistry.register('features/base/media', combineReducers({
ReducerRegistry.register<IMediaState>('features/base/media', combineReducers({
audio: _audio,
screenshare: _screenshare,
video: _video

View File

@ -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<INetInfoState>(STORE_NAME, (state = DEFAULT_STATE, action): INetInfoState => {
switch (action.type) {
case SET_NETWORK_INFO:
return assign(state, {

View File

@ -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,

View File

@ -140,7 +140,8 @@ export interface IParticipantsState {
* added/removed/modified.
* @returns {Participant[]}
*/
ReducerRegistry.register('features/base/participants', (state: IParticipantsState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IParticipantsState>('features/base/participants',
(state = DEFAULT_STATE, action): IParticipantsState => {
switch (action.type) {
case PARTICIPANT_ID_CHANGED: {
const { local } = state;

View File

@ -52,7 +52,7 @@ class ReducerRegistry {
* @param {Reducer} reducer - A Redux reducer.
* @returns {void}
*/
register(name: string, reducer: Reducer<any, any>) {
register<S>(name: string, reducer: Reducer<S, any>) {
this._elements[name] = reducer;
}
}

View File

@ -40,7 +40,8 @@ export interface IResponsiveUIState {
}
}
ReducerRegistry.register('features/base/responsive-ui', (state: IResponsiveUIState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IResponsiveUIState>('features/base/responsive-ui',
(state = DEFAULT_STATE, action): IResponsiveUIState => {
switch (action.type) {
case CLIENT_RESIZED: {
return {

View File

@ -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<ISettingsState>(STORE_NAME, (state = DEFAULT_STATE, action): ISettingsState => {
switch (action.type) {
case APP_WILL_MOUNT:
return _initSettings(state);

View File

@ -51,9 +51,9 @@ export type ISoundsState = Map<string, Sound>;
/**
* The base/sounds feature's reducer.
*/
ReducerRegistry.register(
ReducerRegistry.register<ISoundsState>(
'features/base/sounds',
(state: ISoundsState = DEFAULT_STATE, action) => {
(state = DEFAULT_STATE, action): ISoundsState => {
switch (action.type) {
case _ADD_AUDIO_ELEMENT:
case _REMOVE_AUDIO_ELEMENT:

View File

@ -18,9 +18,9 @@ export interface ITestingState {
connectionState: string;
}
ReducerRegistry.register(
ReducerRegistry.register<ITestingState>(
'features/testing',
(state: ITestingState = INITIAL_STATE, action) => {
(state = INITIAL_STATE, action): ITestingState => {
switch (action.type) {
case SET_CONNECTION_STATE:
return _setConnectionState(state, action);

View File

@ -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<ITracksState>('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<INoSrcDataState>('features/base/no-src-data', (state = {}, action): INoSrcDataState => {
switch (action.type) {
case SET_NO_SRC_DATA_NOTIFICATION_UID:
return set(state, 'noSrcDataNotificationUid', action.uid);

View File

@ -8,7 +8,8 @@ export interface IUserInteractionState {
}
ReducerRegistry.register('features/base/user-interaction', (state: IUserInteractionState = {}, action) => {
ReducerRegistry.register<IUserInteractionState>('features/base/user-interaction',
(state = {}, action): IUserInteractionState => {
switch (action.type) {
case APP_WILL_MOUNT:
case APP_WILL_UNMOUNT:

View File

@ -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<IBreakoutRoomsState>(FEATURE_KEY, (state = DEFAULT_STATE, action): IBreakoutRoomsState => {
switch (action.type) {
case _UPDATE_ROOM_COUNTER:
return {

View File

@ -58,7 +58,7 @@ PersistenceRegistry.register(STORE_NAME, {
msAuthState: true
});
ReducerRegistry.register(STORE_NAME, (state: ICalendarSyncState = DEFAULT_STATE, action) => {
ReducerRegistry.register<ICalendarSyncState>(STORE_NAME, (state = DEFAULT_STATE, action): ICalendarSyncState => {
switch (action.type) {
case CLEAR_CALENDAR_INTEGRATION:
return DEFAULT_STATE;

View File

@ -55,7 +55,7 @@ export interface IChatState {
privateMessageRecipient?: Participant;
}
ReducerRegistry.register('features/chat', (state: IChatState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IChatState>('features/chat', (state = DEFAULT_STATE, action): IChatState => {
switch (action.type) {
case ADD_MESSAGE: {
const newMessage: IMessage = {

View File

@ -6,7 +6,7 @@ export interface IDeepLinkingState {
launchInWeb?: boolean;
}
ReducerRegistry.register('features/deep-linking', (state = {}, action) => {
ReducerRegistry.register<IDeepLinkingState>('features/deep-linking', (state = {}, action): IDeepLinkingState => {
switch (action.type) {
case OPEN_WEB_APP: {
return {

View File

@ -19,7 +19,7 @@ export interface IDropboxState {
*/
PersistenceRegistry.register(STORE_NAME);
ReducerRegistry.register(STORE_NAME, (state: IDropboxState = {}, action) => {
ReducerRegistry.register<IDropboxState>(STORE_NAME, (state = {}, action): IDropboxState => {
switch (action.type) {
case UPDATE_DROPBOX_TOKEN:
return {

View File

@ -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<IDynamicBrandingState>(STORE_NAME, (state = DEFAULT_STATE, action): IDynamicBrandingState => {
switch (action.type) {
case SET_DYNAMIC_BRANDING_DATA: {
const {

View File

@ -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<IE2EEState>('features/e2ee', (state = DEFAULT_STATE, action): IE2EEState => {
switch (action.type) {
case TOGGLE_E2EE:
return {

View File

@ -26,9 +26,9 @@ export interface IEtherpadState {
/**
* Reduces the Redux actions of the feature features/etherpad.
*/
ReducerRegistry.register(
ReducerRegistry.register<IEtherpadState>(
'features/etherpad',
(state: IEtherpadState = DEFAULT_STATE, action) => {
(state = DEFAULT_STATE, action): IEtherpadState => {
switch (action.type) {
case SET_DOCUMENT_EDITING_STATUS:
return {

View File

@ -46,7 +46,8 @@ export interface IFaceLandmarksState {
recognitionActive: boolean;
}
ReducerRegistry.register('features/face-landmarks', (state: IFaceLandmarksState = defaultState, action) => {
ReducerRegistry.register<IFaceLandmarksState>('features/face-landmarks',
(state = defaultState, action): IFaceLandmarksState => {
switch (action.type) {
case ADD_FACE_EXPRESSION: {
return {

View File

@ -24,9 +24,9 @@ export interface IFeedbackState {
/**
* Reduces the Redux actions of the feature features/feedback.
*/
ReducerRegistry.register(
ReducerRegistry.register<IFeedbackState>(
'features/feedback',
(state: IFeedbackState = DEFAULT_STATE, action) => {
(state = DEFAULT_STATE, action): IFeedbackState => {
switch (action.type) {
case CANCEL_FEEDBACK: {
return {

View File

@ -258,9 +258,9 @@ export interface IFilmstripState {
}
}
ReducerRegistry.register(
ReducerRegistry.register<IFilmstripState>(
'features/filmstrip',
(state: IFilmstripState = DEFAULT_STATE, action) => {
(state = DEFAULT_STATE, action): IFilmstripState => {
switch (action.type) {
case SET_FILMSTRIP_ENABLED:
return {

View File

@ -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<IFollowMeState>(
'features/follow-me',
(state: IFollowMeState = {}, action) => {
(state = {}, action): IFollowMeState => {
switch (action.type) {
case SET_FOLLOW_ME_MODERATOR: {

View File

@ -23,9 +23,9 @@ export interface IGifsState {
menuOpen: boolean;
}
ReducerRegistry.register(
ReducerRegistry.register<IGifsState>(
'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
});

View File

@ -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<IGoogleApiState>('features/google-api',
(state = DEFAULT_STATE, action): IGoogleApiState => {
switch (action.type) {
case SET_GOOGLE_API_STATE:
return {

View File

@ -37,7 +37,7 @@ export interface IInviteState {
sipUri?: string;
}
ReducerRegistry.register('features/invite', (state: IInviteState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IInviteState>('features/invite', (state = DEFAULT_STATE, action): IInviteState => {
switch (action.type) {
case ADD_PENDING_INVITE_REQUEST:
return {

View File

@ -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<IJaaSState>(
'features/jaas', (state = DEFAULT_STATE, action): IJaaSState => {
switch (action.type) {
case SET_DETAILS: {

View File

@ -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<ILargeVideoState>('features/large-video', (state = {}, action): ILargeVideoState => {
switch (action.type) {
// When conference is joined, we update ID of local participant from default

View File

@ -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<ILobbyState>('features/lobby', (state = DEFAULT_STATE, action): ILobbyState => {
switch (action.type) {
case CONFERENCE_JOINED:
case CONFERENCE_LEFT:

View File

@ -13,7 +13,8 @@ const DEFAULT_STATE = {
subscriptions: []
};
ReducerRegistry.register('features/mobile/audio-mode', (state: IMobileAudioModeState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IMobileAudioModeState>('features/mobile/audio-mode',
(state = DEFAULT_STATE, action): IMobileAudioModeState => {
switch (action.type) {
case _SET_AUDIOMODE_DEVICES: {
const { devices } = action;

View File

@ -17,7 +17,7 @@ const DEFAULT_STATE = {
appState: 'active'
};
ReducerRegistry.register('features/background', (state: IBackgroundState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IBackgroundState>('features/background', (state = DEFAULT_STATE, action): IBackgroundState => {
switch (action.type) {
case _SET_APP_STATE_LISTENER:
return {

View File

@ -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;
});

View File

@ -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<ICallIntegrationState>(
'features/call-integration',
(state = {}, action): ICallIntegrationState => {
switch (action.type) {
case _SET_CALL_INTEGRATION_SUBSCRIPTIONS:
return set(state, 'subscriptions', action.subscriptions);
}
return state;
});

View File

@ -10,7 +10,8 @@ const DEFAULT_STATE = {
screenShares: []
};
ReducerRegistry.register('features/mobile/external-api', (state: IMobileExternalApiState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IMobileExternalApiState>('features/mobile/external-api',
(state = DEFAULT_STATE, action): IMobileExternalApiState => {
switch (action.type) {
case SCREEN_SHARE_PARTICIPANTS_UPDATED: {
return {

View File

@ -6,7 +6,7 @@ export interface IFullScreenState {
listener?: Function;
}
ReducerRegistry.register('features/full-screen', (state: IFullScreenState = {}, action) => {
ReducerRegistry.register<IFullScreenState>('features/full-screen', (state = {}, action): IFullScreenState => {
switch (action.type) {
case _SET_IMMERSIVE_LISTENER:
return {

View File

@ -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<IMobileWatchOSState>('features/mobile/watchos',
(state = INITIAL_STATE, action): IMobileWatchOSState => {
switch (action.type) {
case SET_CONFERENCE_TIMESTAMP: {
return assign(state, {

View File

@ -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<INoAudioSignalState>('features/no-audio-signal', (state = {}, action): INoAudioSignalState => {
switch (action.type) {
case SET_NO_AUDIO_SIGNAL_NOTIFICATION_UID:
return set(state, 'noAudioSignalNotificationUid', action.uid);

View File

@ -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<INoiseDetectionState>('features/noise-detection',
(state = {}, action): INoiseDetectionState => {
switch (action.type) {
case SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID:
return set(state, 'noisyAudioInputNotificationUid', action.uid);

View File

@ -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<INoiseSuppressionState>('features/noise-suppression',
(state = DEFAULT_STATE, action): INoiseSuppressionState => {
const { enabled } = action;
switch (action.type) {

View File

@ -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<INotificationsState>('features/notifications',
(state = DEFAULT_STATE, action): INotificationsState => {
switch (action.type) {
case CLEAR_NOTIFICATIONS:
return {

View File

@ -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<IOverlayState>('features/overlay', (state = {}, action): IOverlayState => {
switch (action.type) {
case CONFIG_WILL_LOAD:
return _setShowLoadConfigOverlay(state, Boolean(action.room));

View File

@ -25,7 +25,7 @@ export interface IPollsState {
};
}
ReducerRegistry.register('features/polls', (state: IPollsState = INITIAL_STATE, action) => {
ReducerRegistry.register<IPollsState>('features/polls', (state = INITIAL_STATE, action): IPollsState => {
switch (action.type) {
case CHANGE_VOTE: {

View File

@ -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<IPowerMonitorState>('features/power-monitor', (state = {}, action): IPowerMonitorState => {
switch (action.type) {
case SET_TRANSPORT:
return _setTransport(state, action.transport);

View File

@ -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<IPrejoinState>(
'features/prejoin', (state = DEFAULT_STATE, action): IPrejoinState => {
switch (action.type) {
case PREJOIN_JOINING_IN_PROGRESS:
return {

View File

@ -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(() => {

View File

@ -77,9 +77,9 @@ function _getInitialState(): IReactionsState {
};
}
ReducerRegistry.register(
ReducerRegistry.register<IReactionsState>(
'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 ?? []
};
}

View File

@ -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<IRecentListState>(STORE_NAME, (state = DEFAULT_STATE, action): IRecentListState => {
if (isRecentListEnabled()) {
switch (action.type) {
case DELETE_RECENT_LIST_ENTRY:

View File

@ -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<IRecordingState>(STORE_NAME,
(state = DEFAULT_STATE, action): IRecordingState => {
switch (action.type) {
case CLEAR_RECORDING_SESSIONS:

View File

@ -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<IRemoteControlState>(
'features/remote-control', (state = DEFAULT_STATE, action): IRemoteControlState => {
switch (action.type) {
case CAPTURE_EVENTS:
return {

View File

@ -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<IScreenShareState>('features/screen-share', (state = {}, action): IScreenShareState => {
const { captureFrameRate, isSharingAudio, desktopAudioTrack } = action;
switch (action.type) {

View File

@ -15,7 +15,8 @@ export interface IScreenshotCaptureState {
capturesEnabled: boolean;
}
ReducerRegistry.register('features/screenshot-capture', (state: IScreenshotCaptureState = DEFAULT_STATE, action) => {
ReducerRegistry.register<IScreenshotCaptureState>('features/screenshot-capture',
(state = DEFAULT_STATE, action): IScreenshotCaptureState => {
switch (action.type) {
case SET_SCREENSHOT_CAPTURE: {
return {

View File

@ -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<ISharedVideoState>('features/shared-video',
(state = initialState, action): ISharedVideoState => {
const { videoUrl, status, time, ownerId, disabled, muted, volume } = action;
switch (action.type) {

View File

@ -31,7 +31,8 @@ export interface ISpeakerStatsState {
stats: Object;
}
ReducerRegistry.register('features/speaker-stats', (state: ISpeakerStatsState = INITIAL_STATE, action) => {
ReducerRegistry.register<ISpeakerStatsState>('features/speaker-stats',
(state = INITIAL_STATE, action): ISpeakerStatsState => {
switch (action.type) {
case INIT_SEARCH:
return _updateCriteria(state, action);

View File

@ -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<ISubtitlesState>('features/subtitles', (
state = defaultState, action): ISubtitlesState => {
switch (action.type) {
case REMOVE_TRANSCRIPT_MESSAGE:
return _removeTranscriptMessage(state, action);

View File

@ -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<ITalkWhileMutedState>('features/talk-while-muted',
(state = {}, action): ITalkWhileMutedState => {
switch (action.type) {
case SET_CURRENT_NOTIFICATION_UID:
return set(state, 'currentNotificationUid', action.uid);

View File

@ -83,9 +83,9 @@ export interface IToolboxState {
visible: boolean;
}
ReducerRegistry.register(
ReducerRegistry.register<IToolboxState>(
'features/toolbox',
(state: IToolboxState = INITIAL_STATE, action): IToolboxState => {
(state = INITIAL_STATE, action): IToolboxState => {
switch (action.type) {
case CLEAR_TOOLBOX_TIMEOUT:
return {

View File

@ -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<ITranscribingState>('features/transcribing',
(state = _getInitialState(), action): ITranscribingState => {
switch (action.type) {
case _TRANSCRIBER_JOINED:
return {

View File

@ -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<IVideoLayoutState>(STORE_NAME, (state = DEFAULT_STATE, action): IVideoLayoutState => {
switch (action.type) {
case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED:
case VIRTUAL_SCREENSHARE_REMOTE_PARTICIPANTS_UPDATED:

View File

@ -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<IVideoQualityPersistedState>('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<IVideoQualityState>('features/video-quality',
(state = DEFAULT_STATE, action): IVideoQualityState => {
switch (action.type) {
case SET_CONFIG:
return _setConfig(state, action);

View File

@ -6,8 +6,8 @@ export interface IVideoSipGW {
status?: string;
}
ReducerRegistry.register(
'features/videosipgw', (state: IVideoSipGW = {}, action): IVideoSipGW => {
ReducerRegistry.register<IVideoSipGW>(
'features/videosipgw', (state = {}, action): IVideoSipGW => {
switch (action.type) {
case SIP_GW_AVAILABILITY_CHANGED: {
return {

View File

@ -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<IVirtualBackground>(STORE_NAME, (state = {}, action): IVirtualBackground => {
const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action;
/**