diff --git a/react/features/app/types.ts b/react/features/app/types.ts index 896371e59..41ffe3bcb 100644 --- a/react/features/app/types.ts +++ b/react/features/app/types.ts @@ -6,6 +6,8 @@ import { IAudioOnlyState } from '../base/audio-only/reducer'; import { IConferenceState } from '../base/conference/reducer'; import { IConfig } from '../base/config/configType'; import { IConnectionState } from '../base/connection/reducer'; +import { IDevicesState } from '../base/devices/reducer'; +import { IDialogState } from '../base/dialog/reducer'; export interface IStore { getState: Function, @@ -20,5 +22,7 @@ export interface IState { 'features/base/audio-only': IAudioOnlyState, 'features/base/conference': IConferenceState, 'features/base/config': IConfig, - 'features/base/connection': IConnectionState + 'features/base/connection': IConnectionState, + 'features/base/devices': IDevicesState, + 'features/base/dialog': IDialogState } diff --git a/react/features/base/devices/reducer.js b/react/features/base/devices/reducer.ts similarity index 78% rename from react/features/base/devices/reducer.js rename to react/features/base/devices/reducer.ts index 457be5931..ab5bd5c0f 100644 --- a/react/features/base/devices/reducer.js +++ b/react/features/base/devices/reducer.ts @@ -1,4 +1,5 @@ -import { ReducerRegistry } from '../redux'; +/* eslint-disable import/order */ +import ReducerRegistry from '../redux/ReducerRegistry'; import { ADD_PENDING_DEVICE_REQUEST, @@ -8,10 +9,15 @@ import { SET_VIDEO_INPUT_DEVICE, UPDATE_DEVICE_LIST } from './actionTypes'; + +// @ts-ignore import { groupDevicesByKind } from './functions'; + +// @ts-ignore import logger from './logger'; -const DEFAULT_STATE = { + +const DEFAULT_STATE: IDevicesState = { availableDevices: { audioInput: [], audioOutput: [], @@ -24,10 +30,23 @@ const DEFAULT_STATE = { } }; +export interface IDevicesState { + availableDevices: { + audioInput: MediaDeviceInfo[]; + audioOutput: MediaDeviceInfo[]; + videoInput: MediaDeviceInfo[]; + }; + pendingRequests: Object[]; + permissions: { + audio: boolean; + video: boolean; + } +} + /** * Listen for actions which changes the state of known and used devices. * - * @param {Object} state - The Redux state of the feature features/base/devices. + * @param {IDevicesState} state - The Redux state of the feature features/base/devices. * @param {Object} action - Action object. * @param {string} action.type - Type of action. * @param {Array} action.devices - All available audio and @@ -36,7 +55,7 @@ const DEFAULT_STATE = { */ ReducerRegistry.register( 'features/base/devices', - (state = DEFAULT_STATE, action) => { + (state: IDevicesState = DEFAULT_STATE, action) => { switch (action.type) { case UPDATE_DEVICE_LIST: { const deviceList = groupDevicesByKind(action.devices); diff --git a/react/features/base/dialog/reducer.js b/react/features/base/dialog/reducer.ts similarity index 75% rename from react/features/base/dialog/reducer.js rename to react/features/base/dialog/reducer.ts index 56b47911b..75897d5e0 100644 --- a/react/features/base/dialog/reducer.js +++ b/react/features/base/dialog/reducer.ts @@ -1,4 +1,5 @@ -import { assign, ReducerRegistry } from '../redux'; +import ReducerRegistry from '../redux/ReducerRegistry'; +import { assign } from '../redux/functions'; import { HIDE_DIALOG, @@ -7,16 +8,23 @@ import { OPEN_SHEET } from './actionTypes'; +export interface IDialogState { + component?: Object; + componentProps?: Object; + sheet?: Object; + sheetProps?: Object; +} + /** * Reduces redux actions which show or hide dialogs. * - * @param {State} state - The current redux state. + * @param {IDialogState} state - The current redux state. * @param {Action} action - The redux action to reduce. * @param {string} action.type - The type of the redux action to reduce.. * @returns {State} The next redux state that is the result of reducing the * specified action. */ -ReducerRegistry.register('features/base/dialog', (state = {}, action) => { +ReducerRegistry.register('features/base/dialog', (state: IDialogState = {}, action) => { switch (action.type) { case HIDE_DIALOG: { const { component } = action;