Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref: Convert some reducers to TS (#11904)
Robert Pintilii44e5fa35afdb
diff --git a/react/features/app/types.ts b/react/features/app/types.tsindex 443f14cde8..b0c3636244 100644--- a/react/features/app/types.ts+++ b/react/features/app/types.ts@@ -15,6 +15,10 @@ import { ILibJitsiMeetState } from '../base/lib-jitsi-meet/reducer';import { ILoggingState } from '../base/logging/reducer';import { IMediaState } from '../base/media/reducer';import { INetInfoState } from '../base/net-info/reducer';+import { IResponsiveUIState } from '../base/responsive-ui/reducer';+import { ISettingsState } from '../base/settings/reducer';+import { ISoundsState } from '../base/sounds/reducer';+import { ITestingState } from '../base/testing/reducer';import { INoiseSuppressionState } from '../noise-suppression/reducer';export interface IStore {@@ -41,5 +45,9 @@ export interface IState {'features/base/logging': ILoggingState,'features/base/media': IMediaState,'features/base/net-info': INetInfoState,- 'features/noise-suppression': INoiseSuppressionState+ 'features/base/responsive-ui': IResponsiveUIState,+ 'features/base/settings': ISettingsState,+ 'features/base/sounds': ISoundsState,+ 'features/noise-suppression': INoiseSuppressionState,+ 'features/testing': ITestingState}diff --git a/react/features/base/responsive-ui/constants.js b/react/features/base/responsive-ui/constants.tssimilarity index 100%rename from react/features/base/responsive-ui/constants.jsrename to react/features/base/responsive-ui/constants.tsdiff --git a/react/features/base/responsive-ui/reducer.js b/react/features/base/responsive-ui/reducer.tssimilarity index 69%rename from react/features/base/responsive-ui/reducer.jsrename to react/features/base/responsive-ui/reducer.tsindex 122458d77d..92649082d3 100644--- a/react/features/base/responsive-ui/reducer.js+++ b/react/features/base/responsive-ui/reducer.ts@@ -1,6 +1,5 @@-// @flow--import { ReducerRegistry, set } from '../redux';+import ReducerRegistry from '../redux/ReducerRegistry';+import { set } from '../redux/functions';import {CLIENT_RESIZED,@@ -27,7 +26,21 @@ const DEFAULT_STATE = {contextMenuOpened: false};-ReducerRegistry.register('features/base/responsive-ui', (state = DEFAULT_STATE, action) => {+export interface IResponsiveUIState {+ aspectRatio: Symbol;+ clientHeight: number;+ clientWidth: number;+ contextMenuOpened: boolean;+ reducedUI: boolean;+ safeAreaInsets?: {+ bottom: number;+ left: number;+ right: number;+ top: number;+ }+}++ReducerRegistry.register('features/base/responsive-ui', (state: IResponsiveUIState = DEFAULT_STATE, action) => {switch (action.type) {case CLIENT_RESIZED: {return {diff --git a/react/features/base/settings/reducer.js b/react/features/base/settings/reducer.tssimilarity index 64%rename from react/features/base/settings/reducer.jsrename to react/features/base/settings/reducer.tsindex e77c24ce8b..43e8c4775e 100644--- a/react/features/base/settings/reducer.js+++ b/react/features/base/settings/reducer.ts@@ -1,10 +1,12 @@-// @flow-+/* eslint-disable lines-around-comment */+// @ts-ignoreimport { jitsiLocalStorage } from '@jitsi/js-utils';import _ from 'lodash';import { APP_WILL_MOUNT } from '../app/actionTypes';-import { PersistenceRegistry, ReducerRegistry } from '../redux';+import PersistenceRegistry from '../redux/PersistenceRegistry';+import ReducerRegistry from '../redux/ReducerRegistry';+// @ts-ignoreimport { assignIfDefined } from '../util';import { SETTINGS_UPDATED } from './actionTypes';@@ -14,7 +16,7 @@ import { SETTINGS_UPDATED } from './actionTypes';** @type Object*/-const DEFAULT_STATE = {+const DEFAULT_STATE: ISettingsState = {audioOutputDeviceId: undefined,avatarURL: undefined,cameraDeviceId: undefined,@@ -49,16 +51,53 @@ const DEFAULT_STATE = {userSelectedSkipPrejoin: undefined};+export interface ISettingsState {+ audioOutputDeviceId?: string|boolean;+ avatarURL?: string|boolean;+ cameraDeviceId?: string|boolean;+ disableCallIntegration?: boolean;+ disableCrashReporting?: boolean;+ disableP2P?: boolean;+ disableSelfView?: boolean;+ displayName?: string|boolean;+ email?: string|boolean;+ hideShareAudioHelper?: boolean;+ localFlipX?: boolean;+ micDeviceId?: string|boolean;+ serverURL?: string|boolean;+ soundsIncomingMessage?: boolean;+ soundsParticipantJoined?: boolean;+ soundsParticipantKnocking?: boolean;+ soundsParticipantLeft?: boolean;+ soundsReactions?: boolean;+ soundsTalkWhileMuted?: boolean;+ startAudioOnly?: boolean;+ startWithAudioMuted?: boolean;+ startWithVideoMuted?: boolean;+ userSelectedAudioOutputDeviceId?: string|boolean;+ userSelectedAudioOutputDeviceLabel?: string|boolean;+ userSelectedCameraDeviceId?: string|boolean;+ userSelectedCameraDeviceLabel?: string|boolean;+ userSelectedMicDeviceId?: string|boolean;+ userSelectedMicDeviceLabel?: string|boolean;+ userSelectedNotifications?: {+ [key: string]: boolean;+ }|boolean,+ userSelectedSkipPrejoin?: boolean;+}+const STORE_NAME = 'features/base/settings';/*** Sets up the persistence of the feature {@code base/settings}.*/-const filterSubtree = {};+const filterSubtree: ISettingsState = {};// start with the default stateObject.keys(DEFAULT_STATE).forEach(key => {- filterSubtree[key] = true;+ const key1 = key as keyof typeof filterSubtree;++ filterSubtree[key1] = true;});// we want to filter these props, to not be stored as they represent@@ -69,7 +108,7 @@ filterSubtree.micDeviceId = false;PersistenceRegistry.register(STORE_NAME, filterSubtree, DEFAULT_STATE);-ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {+ReducerRegistry.register(STORE_NAME, (state: ISettingsState = DEFAULT_STATE, action) => {switch (action.type) {case APP_WILL_MOUNT:return _initSettings(state);@@ -90,10 +129,10 @@ ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {* - Old Settings.js style data.** @private- * @param {Object} featureState - The current state of the feature.+ * @param {ISettingsState} featureState - The current state of the feature.* @returns {Object}*/-function _initSettings(featureState) {+function _initSettings(featureState: ISettingsState) {let settings = featureState;// Old Settings.js valuesdiff --git a/react/features/base/sounds/reducer.js b/react/features/base/sounds/reducer.tssimilarity index 87%rename from react/features/base/sounds/reducer.jsrename to react/features/base/sounds/reducer.tsindex 939552d22b..f1968f54de 100644--- a/react/features/base/sounds/reducer.js+++ b/react/features/base/sounds/reducer.ts@@ -1,7 +1,8 @@-// @flow-+/* eslint-disable lines-around-comment */+// @ts-ignoreimport type { AudioElement } from '../media';-import { assign, ReducerRegistry } from '../redux';+import ReducerRegistry from '../redux/ReducerRegistry';+import { assign } from '../redux/functions';import {_ADD_AUDIO_ELEMENT,@@ -9,6 +10,7 @@ import {REGISTER_SOUND,UNREGISTER_SOUND} from './actionTypes';+// @ts-ignoreimport logger from './logger';/**@@ -24,16 +26,16 @@ export type Sound = {audioElement?: AudioElement,/**- * This field describes the source of the audio resource to be played. It- * can be either a path to the file or an object depending on the platform- * (native vs web).+ * This field is container for all optional parameters related to the sound.*/- src: Object | string,+ options?: Object,/**- * This field is container for all optional parameters related to the sound.+ * This field describes the source of the audio resource to be played. It+ * can be either a path to the file or an object depending on the platform+ * (native vs web).*/- options: Object+ src?: Object | string}/**@@ -44,12 +46,14 @@ export type Sound = {*/const DEFAULT_STATE = new Map();+export type ISoundsState = Map<string, Sound>;+/*** The base/sounds feature's reducer.*/ReducerRegistry.register('features/base/sounds',- (state = DEFAULT_STATE, action) => {+ (state: ISoundsState = DEFAULT_STATE, action) => {switch (action.type) {case _ADD_AUDIO_ELEMENT:case _REMOVE_AUDIO_ELEMENT:@@ -75,7 +79,7 @@ ReducerRegistry.register(* @private* @returns {Map<string, Sound>}*/-function _addOrRemoveAudioElement(state, action) {+function _addOrRemoveAudioElement(state: ISoundsState, action: any) {const isAddAction = action.type === _ADD_AUDIO_ELEMENT;const nextState = new Map(state);const { soundId } = action;@@ -112,7 +116,7 @@ function _addOrRemoveAudioElement(state, action) {* @private* @returns {Map<string, Sound>}*/-function _registerSound(state, action) {+function _registerSound(state: ISoundsState, action: any) {const nextState = new Map(state);nextState.set(action.soundId, {@@ -133,7 +137,7 @@ function _registerSound(state, action) {* @private* @returns {Map<string, Sound>}*/-function _unregisterSound(state, action) {+function _unregisterSound(state: ISoundsState, action: any) {const nextState = new Map(state);nextState.delete(action.soundId);diff --git a/react/features/base/testing/reducer.js b/react/features/base/testing/reducer.tssimilarity index 75%rename from react/features/base/testing/reducer.jsrename to react/features/base/testing/reducer.tsindex 51ff939caa..38bf06860b 100644--- a/react/features/base/testing/reducer.js+++ b/react/features/base/testing/reducer.ts@@ -1,4 +1,5 @@-import { assign, ReducerRegistry } from '../redux';+import ReducerRegistry from '../redux/ReducerRegistry';+import { assign } from '../redux/functions';import { SET_CONNECTION_STATE } from './actionTypes';@@ -13,9 +14,13 @@ const INITIAL_STATE = {connectionState: ''};+export interface ITestingState {+ connectionState: string;+}+ReducerRegistry.register('features/testing',- (state = INITIAL_STATE, action) => {+ (state: ITestingState = INITIAL_STATE, action) => {switch (action.type) {case SET_CONNECTION_STATE:return _setConnectionState(state, action);@@ -35,6 +40,6 @@ ReducerRegistry.register(* @returns {Object} The new state of the feature testing after the* reduction of the specified action.*/-function _setConnectionState(state, action) {+function _setConnectionState(state: ITestingState, action: any) {return assign(state, { connectionState: action.connectionState });}