ref: Convert reducers to TS (#12101)

This commit is contained in:
Robert Pintilii 2022-09-01 14:00:49 +03:00 committed by GitHub
parent c4557c66aa
commit 3403d7bec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 220 additions and 79 deletions

View File

@ -54,7 +54,21 @@ import { IPollsState } from '../polls/reducer';
import { IPowerMonitorState } from '../power-monitor/reducer'; import { IPowerMonitorState } from '../power-monitor/reducer';
import { IPrejoinState } from '../prejoin/reducer'; import { IPrejoinState } from '../prejoin/reducer';
import { IReactionsState } from '../reactions/reducer'; import { IReactionsState } from '../reactions/reducer';
import { IRecentListState } from '../recent-list/reducer';
import { IRecordingState } from '../recording/reducer';
import { IRemoteControlState } from '../remote-control/reducer';
import { IScreenShareState } from '../screen-share/reducer';
import { IScreenshotCaptureState } from '../screenshot-capture/reducer';
import { ISharedVideoState } from '../shared-video/reducer'; import { ISharedVideoState } from '../shared-video/reducer';
import { ISpeakerStatsState } from '../speaker-stats/reducer';
import { ISubtitlesState } from '../subtitles/reducer';
import { ITalkWhileMutedState } from '../talk-while-muted/reducer';
import { IToolboxState } from '../toolbox/reducer';
import { ITranscribingState } from '../transcribing/reducer';
import { IVideoLayoutState } from '../video-layout/reducer';
import { IVideoQualityPersistedState, IVideoQualityState } from '../video-quality/reducer';
import { IVideoSipGW } from '../videosipgw/reducer';
import { IVirtualBackground } from '../virtual-background/reducer';
export interface IStore { export interface IStore {
dispatch: Function, dispatch: Function,
@ -120,6 +134,22 @@ export interface IState {
'features/power-monitor': IPowerMonitorState, 'features/power-monitor': IPowerMonitorState,
'features/prejoin': IPrejoinState, 'features/prejoin': IPrejoinState,
'features/reactions': IReactionsState, 'features/reactions': IReactionsState,
'features/recent-list': IRecentListState,
'features/recording': IRecordingState,
'features/remote-control': IRemoteControlState,
'features/screen-share': IScreenShareState,
'features/screenshot-capture': IScreenshotCaptureState,
'features/settings': ISettingsState,
'features/shared-video': ISharedVideoState, 'features/shared-video': ISharedVideoState,
'features/testing': ITestingState 'features/speaker-stats': ISpeakerStatsState,
'features/subtitles': ISubtitlesState,
'features/talk-while-muted': ITalkWhileMutedState,
'features/testing': ITestingState,
'features/toolbox': IToolboxState,
'features/transcribing': ITranscribingState,
'features/video-layout': IVideoLayoutState,
'features/video-quality': IVideoQualityState,
'features/video-quality-persistent-storage': IVideoQualityPersistedState,
'features/videosipgw': IVideoSipGW,
'features/virtual-background': IVirtualBackground
} }

View File

@ -1,5 +1,3 @@
/* @flow */
/** /**
* Gets a {@link URL} without hash and query/search params from a specific * Gets a {@link URL} without hash and query/search params from a specific
* {@code URL}. * {@code URL}.

View File

@ -1,19 +1,30 @@
import { getURLWithoutParamsNormalized } from '../base/connection'; /* eslint-disable lines-around-comment */
import { PersistenceRegistry, ReducerRegistry } from '../base/redux'; import { getURLWithoutParamsNormalized } from '../base/connection/utils';
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
_STORE_CURRENT_CONFERENCE, _STORE_CURRENT_CONFERENCE,
_UPDATE_CONFERENCE_DURATION, _UPDATE_CONFERENCE_DURATION,
DELETE_RECENT_LIST_ENTRY DELETE_RECENT_LIST_ENTRY
} from './actionTypes'; } from './actionTypes';
// @ts-ignore
import { isRecentListEnabled } from './functions'; import { isRecentListEnabled } from './functions';
interface IRecent {
conference: string;
date: number;
duration: number;
}
export type IRecentListState = IRecent[];
/** /**
* The default/initial redux state of the feature {@code recent-list}. * The default/initial redux state of the feature {@code recent-list}.
* *
* @type {Array<Object>} * @type {IRecentListState}
*/ */
const DEFAULT_STATE = []; const DEFAULT_STATE: IRecentListState = [];
/** /**
* The max size of the list. * The max size of the list.
@ -35,7 +46,7 @@ PersistenceRegistry.register(STORE_NAME);
/** /**
* Reduces redux actions for the purposes of the feature {@code recent-list}. * Reduces redux actions for the purposes of the feature {@code recent-list}.
*/ */
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { ReducerRegistry.register(STORE_NAME, (state: IRecentListState = DEFAULT_STATE, action) => {
if (isRecentListEnabled()) { if (isRecentListEnabled()) {
switch (action.type) { switch (action.type) {
case DELETE_RECENT_LIST_ENTRY: case DELETE_RECENT_LIST_ENTRY:
@ -55,12 +66,12 @@ ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
/** /**
* Deletes a recent list entry based on the url and date of the item. * Deletes a recent list entry based on the url and date of the item.
* *
* @param {Array<Object>} state - The Redux state. * @param {IRecentListState} state - The Redux state.
* @param {Object} entryId - The ID object of the entry. * @param {Object} entryId - The ID object of the entry.
* @returns {Array<Object>} * @returns {IRecentListState}
*/ */
function _deleteRecentListEntry( function _deleteRecentListEntry(
state: Array<Object>, entryId: Object): Array<Object> { state: Array<IRecent>, entryId: { date: number; url: string; }): Array<IRecent> {
return state.filter(entry => return state.filter(entry =>
entry.conference !== entryId.url || entry.date !== entryId.date); entry.conference !== entryId.url || entry.date !== entryId.date);
} }
@ -68,11 +79,11 @@ function _deleteRecentListEntry(
/** /**
* Adds a new list entry to the redux store. * Adds a new list entry to the redux store.
* *
* @param {Object} state - The redux state of the feature {@code recent-list}. * @param {IRecentListState} state - The redux state of the feature {@code recent-list}.
* @param {Object} action - The redux action. * @param {Object} action - The redux action.
* @returns {Object} * @returns {Object}
*/ */
function _storeCurrentConference(state, { locationURL }) { function _storeCurrentConference(state: IRecentListState, { locationURL }: { locationURL: { href: string } }) {
const conference = locationURL.href; const conference = locationURL.href;
// If the current conference is already in the list, we remove it to re-add // If the current conference is already in the list, we remove it to re-add
@ -96,11 +107,11 @@ function _storeCurrentConference(state, { locationURL }) {
/** /**
* Updates the conference length when left. * Updates the conference length when left.
* *
* @param {Object} state - The redux state of the feature {@code recent-list}. * @param {IRecentListState} state - The redux state of the feature {@code recent-list}.
* @param {Object} action - The redux action. * @param {Object} action - The redux action.
* @returns {Object} The next redux state of the feature {@code recent-list}. * @returns {Object} The next redux state of the feature {@code recent-list}.
*/ */
function _updateConferenceDuration(state, { locationURL }) { function _updateConferenceDuration(state: IRecentListState, { locationURL }: { locationURL: { href: string } }) {
if (locationURL && locationURL.href && state.length) { if (locationURL && locationURL.href && state.length) {
const mostRecentIndex = state.length - 1; const mostRecentIndex = state.length - 1;
const mostRecent = state[mostRecentIndex]; const mostRecent = state[mostRecentIndex];

View File

@ -1,4 +1,4 @@
import { ReducerRegistry } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
CLEAR_RECORDING_SESSIONS, CLEAR_RECORDING_SESSIONS,
@ -16,6 +16,27 @@ const DEFAULT_STATE = {
sessionDatas: [] sessionDatas: []
}; };
interface SessionData {
error?: Error;
id?: string;
initiator?: Object;
liveStreamViewURL?: string;
mode?: string;
status?: string;
terminator?: Object;
timestamp?: number;
}
export interface IRecordingState {
disableHighlightMeetingMoment: boolean;
pendingNotificationUids: {
[key: string]: number|undefined;
};
selectedRecordingService: string;
sessionDatas: Array<SessionData>;
streamKey?: string;
}
/** /**
* The name of the Redux store this feature stores its state in. * The name of the Redux store this feature stores its state in.
*/ */
@ -25,7 +46,7 @@ const STORE_NAME = 'features/recording';
* Reduces the Redux actions of the feature features/recording. * Reduces the Redux actions of the feature features/recording.
*/ */
ReducerRegistry.register(STORE_NAME, ReducerRegistry.register(STORE_NAME,
(state = DEFAULT_STATE, action) => { (state: IRecordingState = DEFAULT_STATE, action) => {
switch (action.type) { switch (action.type) {
case CLEAR_RECORDING_SESSIONS: case CLEAR_RECORDING_SESSIONS:
@ -86,7 +107,7 @@ ReducerRegistry.register(STORE_NAME,
* @private * @private
* @returns {Array} The session datas with the updated session data added. * @returns {Array} The session datas with the updated session data added.
*/ */
function _updateSessionDatas(sessionDatas, newSessionData) { function _updateSessionDatas(sessionDatas: SessionData[], newSessionData: SessionData) {
const hasExistingSessionData = sessionDatas.find( const hasExistingSessionData = sessionDatas.find(
sessionData => sessionData.id === newSessionData.id); sessionData => sessionData.id === newSessionData.id);
let newSessionDatas; let newSessionDatas;

View File

@ -1,4 +1,5 @@
import { ReducerRegistry, set } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
import { import {
CAPTURE_EVENTS, CAPTURE_EVENTS,
@ -23,11 +24,25 @@ const DEFAULT_STATE = {
} }
}; };
export interface IRemoteControlState {
active: boolean;
controller: {
controlled?: string;
isCapturingEvents: boolean;
requestedParticipant?: string;
};
receiver: {
controller?: string;
enabled: boolean;
transport?: Object;
}
}
/** /**
* Listen for actions that mutate the remote control state. * Listen for actions that mutate the remote control state.
*/ */
ReducerRegistry.register( ReducerRegistry.register(
'features/remote-control', (state = DEFAULT_STATE, action) => { 'features/remote-control', (state: IRemoteControlState = DEFAULT_STATE, action) => {
switch (action.type) { switch (action.type) {
case CAPTURE_EVENTS: case CAPTURE_EVENTS:
return { return {

View File

@ -1,5 +1,5 @@
import { ReducerRegistry } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
SET_SCREEN_AUDIO_SHARE_STATE, SET_SCREEN_AUDIO_SHARE_STATE,
@ -7,10 +7,16 @@ import {
SET_SCREENSHARE_TRACKS SET_SCREENSHARE_TRACKS
} from './actionTypes'; } from './actionTypes';
export interface IScreenShareState {
captureFrameRate?: number;
desktopAudioTrack?: Object;
isSharingAudio?: boolean;
}
/** /**
* Reduces the Redux actions of the feature features/screen-share. * Reduces the Redux actions of the feature features/screen-share.
*/ */
ReducerRegistry.register('features/screen-share', (state = {}, action) => { ReducerRegistry.register('features/screen-share', (state: IScreenShareState = {}, action) => {
const { captureFrameRate, isSharingAudio, desktopAudioTrack } = action; const { captureFrameRate, isSharingAudio, desktopAudioTrack } = action;
switch (action.type) { switch (action.type) {

View File

@ -1,6 +1,5 @@
// @flow import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
import { SET_SCREENSHOT_CAPTURE } from './actionTypes'; import { SET_SCREENSHOT_CAPTURE } from './actionTypes';
@ -12,7 +11,11 @@ const DEFAULT_STATE = {
capturesEnabled: false capturesEnabled: false
}; };
ReducerRegistry.register('features/screenshot-capture', (state = DEFAULT_STATE, action) => { export interface IScreenshotCaptureState {
capturesEnabled: boolean;
}
ReducerRegistry.register('features/screenshot-capture', (state: IScreenshotCaptureState = DEFAULT_STATE, action) => {
switch (action.type) { switch (action.type) {
case SET_SCREENSHOT_CAPTURE: { case SET_SCREENSHOT_CAPTURE: {
return { return {

View File

@ -1,13 +1,16 @@
// @flow import ReducerRegistry from '../base/redux/ReducerRegistry';
import { ReducerRegistry } from '../base/redux';
import { import {
SET_AUDIO_SETTINGS_VISIBILITY, SET_AUDIO_SETTINGS_VISIBILITY,
SET_VIDEO_SETTINGS_VISIBILITY SET_VIDEO_SETTINGS_VISIBILITY
} from './actionTypes'; } from './actionTypes';
ReducerRegistry.register('features/settings', (state = {}, action) => { export interface ISettingsState {
audioSettingsVisible?: boolean;
videoSettingsVisible?: boolean;
}
ReducerRegistry.register('features/settings', (state: ISettingsState = {}, action) => {
switch (action.type) { switch (action.type) {
case SET_AUDIO_SETTINGS_VISIBILITY: case SET_AUDIO_SETTINGS_VISIBILITY:
return { return {

View File

@ -1,8 +1,6 @@
// @flow
import _ from 'lodash'; import _ from 'lodash';
import { ReducerRegistry } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
INIT_SEARCH, INIT_SEARCH,
@ -25,7 +23,15 @@ const INITIAL_STATE = {
showFaceExpressions: false showFaceExpressions: false
}; };
ReducerRegistry.register('features/speaker-stats', (state = _getInitialState(), action) => { export interface ISpeakerStatsState {
criteria: string|null;
isOpen: boolean;
pendingReorder: boolean;
showFaceExpressions: boolean;
stats: Object;
}
ReducerRegistry.register('features/speaker-stats', (state: ISpeakerStatsState = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case INIT_SEARCH: case INIT_SEARCH:
return _updateCriteria(state, action); return _updateCriteria(state, action);
@ -46,15 +52,6 @@ ReducerRegistry.register('features/speaker-stats', (state = _getInitialState(),
return state; return state;
}); });
/**
* Gets the initial state of the feature speaker-stats.
*
* @returns {Object}
*/
function _getInitialState() {
return INITIAL_STATE;
}
/** /**
* Reduces a specific Redux action INIT_SEARCH of the feature * Reduces a specific Redux action INIT_SEARCH of the feature
* speaker-stats. * speaker-stats.
@ -64,7 +61,7 @@ function _getInitialState() {
* @private * @private
* @returns {Object} The new state after the reduction of the specified action. * @returns {Object} The new state after the reduction of the specified action.
*/ */
function _updateCriteria(state, { criteria }) { function _updateCriteria(state: ISpeakerStatsState, { criteria }: { criteria: string|null }) {
return _.assign( return _.assign(
{}, {},
state, state,
@ -86,7 +83,7 @@ function _updateCriteria(state, { criteria }) {
* @private * @private
* @returns {Object} - The new state after the reduction of the specified action. * @returns {Object} - The new state after the reduction of the specified action.
*/ */
function _updateStats(state, { stats }) { function _updateStats(state: ISpeakerStatsState, { stats }: { stats: any }) {
const finalStats = state.pendingReorder ? stats : state.stats; const finalStats = state.pendingReorder ? stats : state.stats;
if (!state.pendingReorder) { if (!state.pendingReorder) {
@ -122,7 +119,7 @@ function _updateStats(state, { stats }) {
* @private * @private
* @returns {Object} The new state after the reduction of the specified action. * @returns {Object} The new state after the reduction of the specified action.
*/ */
function _initReorderStats(state) { function _initReorderStats(state: ISpeakerStatsState) {
return _.assign( return _.assign(
{}, {},
state, state,

View File

@ -1,4 +1,4 @@
import { ReducerRegistry } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
REMOVE_TRANSCRIPT_MESSAGE, REMOVE_TRANSCRIPT_MESSAGE,
@ -14,12 +14,18 @@ const defaultState = {
_language: 'transcribing.subtitlesOff' _language: 'transcribing.subtitlesOff'
}; };
export interface ISubtitlesState {
_language: string;
_requestingSubtitles: boolean;
_transcriptMessages: Map<string, Object>;
}
/** /**
* Listen for actions for the transcription feature to be used by the actions * Listen for actions for the transcription feature to be used by the actions
* to update the rendered transcription subtitles. * to update the rendered transcription subtitles.
*/ */
ReducerRegistry.register('features/subtitles', ( ReducerRegistry.register('features/subtitles', (
state = defaultState, action) => { state: ISubtitlesState = defaultState, action) => {
switch (action.type) { switch (action.type) {
case REMOVE_TRANSCRIPT_MESSAGE: case REMOVE_TRANSCRIPT_MESSAGE:
return _removeTranscriptMessage(state, action); return _removeTranscriptMessage(state, action);
@ -49,7 +55,7 @@ ReducerRegistry.register('features/subtitles', (
* @returns {Object} The new state of the feature transcription after the * @returns {Object} The new state of the feature transcription after the
* reduction of the specified action. * reduction of the specified action.
*/ */
function _removeTranscriptMessage(state, { transcriptMessageID }) { function _removeTranscriptMessage(state: ISubtitlesState, { transcriptMessageID }: { transcriptMessageID: string }) {
const newTranscriptMessages = new Map(state._transcriptMessages); const newTranscriptMessages = new Map(state._transcriptMessages);
// Deletes the key from Map once a final message arrives. // Deletes the key from Map once a final message arrives.
@ -70,8 +76,8 @@ function _removeTranscriptMessage(state, { transcriptMessageID }) {
* @returns {Object} The new state of the feature transcription after the * @returns {Object} The new state of the feature transcription after the
* reduction of the specified action. * reduction of the specified action.
*/ */
function _updateTranscriptMessage(state, function _updateTranscriptMessage(state: ISubtitlesState, { transcriptMessageID, newTranscriptMessage }:
{ transcriptMessageID, newTranscriptMessage }) { { newTranscriptMessage: Object, transcriptMessageID: string }) {
const newTranscriptMessages = new Map(state._transcriptMessages); const newTranscriptMessages = new Map(state._transcriptMessages);
// Updates the new message for the given key in the Map. // Updates the new message for the given key in the Map.

View File

@ -1,13 +1,16 @@
// @flow import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
import { ReducerRegistry, set } from '../base/redux';
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes'; import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
export interface ITalkWhileMutedState {
currentNotificationUid?: number;
}
/** /**
* Reduces the redux actions of the feature talk while muted. * Reduces the redux actions of the feature talk while muted.
*/ */
ReducerRegistry.register('features/talk-while-muted', (state = { }, action) => { ReducerRegistry.register('features/talk-while-muted', (state: ITalkWhileMutedState = { }, action) => {
switch (action.type) { switch (action.type) {
case SET_CURRENT_NOTIFICATION_UID: case SET_CURRENT_NOTIFICATION_UID:
return set(state, 'currentNotificationUid', action.uid); return set(state, 'currentNotificationUid', action.uid);

View File

@ -1,6 +1,5 @@
// @flow import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
import { ReducerRegistry, set } from '../base/redux';
import { import {
CLEAR_TOOLBOX_TIMEOUT, CLEAR_TOOLBOX_TIMEOUT,
@ -73,9 +72,20 @@ const INITIAL_STATE = {
visible: false visible: false
}; };
export interface IToolboxState {
enabled: boolean;
fullScreen?: boolean;
hangupMenuVisible: boolean;
hovered: boolean;
overflowDrawer: boolean;
overflowMenuVisible: boolean;
timeoutID?: number|null;
visible: boolean;
}
ReducerRegistry.register( ReducerRegistry.register(
'features/toolbox', 'features/toolbox',
(state: Object = INITIAL_STATE, action: Object) => { (state: IToolboxState = INITIAL_STATE, action): IToolboxState => {
switch (action.type) { switch (action.type) {
case CLEAR_TOOLBOX_TIMEOUT: case CLEAR_TOOLBOX_TIMEOUT:
return { return {

View File

@ -1,5 +1,4 @@
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { ReducerRegistry } from '../base/redux';
import { import {
_TRANSCRIBER_JOINED, _TRANSCRIBER_JOINED,
@ -59,11 +58,20 @@ function _getInitialState() {
}; };
} }
export interface ITranscribingState {
isDialing: boolean;
isTerminating: boolean;
isTranscribing: boolean;
pendingNotificationUid?: number;
potentialTranscriberJIDs: string[];
transcriberJID?: string|null;
}
/** /**
* Reduces the Redux actions of the feature features/transcribing. * Reduces the Redux actions of the feature features/transcribing.
*/ */
ReducerRegistry.register('features/transcribing', ReducerRegistry.register('features/transcribing',
(state = _getInitialState(), action) => { (state: ITranscribingState = _getInitialState(), action): ITranscribingState => {
switch (action.type) { switch (action.type) {
case _TRANSCRIBER_JOINED: case _TRANSCRIBER_JOINED:
return { return {

View File

@ -1,6 +1,4 @@
// @flow import ReducerRegistry from '../base/redux/ReducerRegistry';
import { ReducerRegistry } from '../base/redux';
import { import {
SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED, SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED,
@ -33,9 +31,15 @@ const DEFAULT_STATE = {
tileViewEnabled: undefined tileViewEnabled: undefined
}; };
export interface IVideoLayoutState {
carMode: boolean;
remoteScreenShares: string[];
tileViewEnabled?: boolean;
}
const STORE_NAME = 'features/video-layout'; const STORE_NAME = 'features/video-layout';
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { ReducerRegistry.register(STORE_NAME, (state: IVideoLayoutState = DEFAULT_STATE, action): IVideoLayoutState => {
switch (action.type) { switch (action.type) {
case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED: case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED:
case VIRTUAL_SCREENSHARE_REMOTE_PARTICIPANTS_UPDATED: case VIRTUAL_SCREENSHARE_REMOTE_PARTICIPANTS_UPDATED:

View File

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

View File

@ -1,8 +1,13 @@
import { SET_CONFIG } from '../base/config'; import { SET_CONFIG } from '../base/config/actionTypes';
import { PersistenceRegistry, ReducerRegistry, set } from '../base/redux'; import { IConfig } from '../base/config/configType';
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
import { SET_MAX_RECEIVER_VIDEO_QUALITY, SET_PREFERRED_VIDEO_QUALITY } from './actionTypes'; import { SET_MAX_RECEIVER_VIDEO_QUALITY, SET_PREFERRED_VIDEO_QUALITY } from './actionTypes';
import { VIDEO_QUALITY_LEVELS } from './constants'; import { VIDEO_QUALITY_LEVELS } from './constants';
/* eslint-disable-next-line lines-around-comment */
// @ts-ignore
import { validateMinHeightForQualityLvl } from './functions'; import { validateMinHeightForQualityLvl } from './functions';
import logger from './logger'; import logger from './logger';
@ -15,12 +20,23 @@ const DEFAULT_STATE = {
DEFAULT_STATE.minHeightForQualityLvl.set(360, VIDEO_QUALITY_LEVELS.STANDARD); DEFAULT_STATE.minHeightForQualityLvl.set(360, VIDEO_QUALITY_LEVELS.STANDARD);
DEFAULT_STATE.minHeightForQualityLvl.set(720, VIDEO_QUALITY_LEVELS.HIGH); DEFAULT_STATE.minHeightForQualityLvl.set(720, VIDEO_QUALITY_LEVELS.HIGH);
export interface IVideoQualityState {
maxReceiverVideoQuality: number;
minHeightForQualityLvl: Map<number, number>;
preferredVideoQuality: number;
}
export interface IVideoQualityPersistedState {
persistedPrefferedVideoQuality?: number;
}
// When the persisted state is initialized the current state (for example the default state) is erased. // When the persisted state is initialized the current state (for example the default state) is erased.
// In order to workaround this issue we need additional state for the persisted properties. // In order to workaround this issue we need additional state for the persisted properties.
PersistenceRegistry.register('features/video-quality-persistent-storage'); PersistenceRegistry.register('features/video-quality-persistent-storage');
ReducerRegistry.register('features/video-quality-persistent-storage', (state = {}, action) => { ReducerRegistry.register('features/video-quality-persistent-storage',
(state: IVideoQualityPersistedState = {}, action): IVideoQualityPersistedState => {
switch (action.type) { switch (action.type) {
case SET_PREFERRED_VIDEO_QUALITY: { case SET_PREFERRED_VIDEO_QUALITY: {
const { preferredVideoQuality } = action; const { preferredVideoQuality } = action;
@ -35,7 +51,8 @@ ReducerRegistry.register('features/video-quality-persistent-storage', (state = {
return state; return state;
}); });
ReducerRegistry.register('features/video-quality', (state = DEFAULT_STATE, action) => { ReducerRegistry.register('features/video-quality',
(state: IVideoQualityState = DEFAULT_STATE, action): IVideoQualityState => {
switch (action.type) { switch (action.type) {
case SET_CONFIG: case SET_CONFIG:
return _setConfig(state, action); return _setConfig(state, action);
@ -65,7 +82,7 @@ ReducerRegistry.register('features/video-quality', (state = DEFAULT_STATE, actio
* @private * @private
* @returns {Object} The new state after the reduction of the specified action. * @returns {Object} The new state after the reduction of the specified action.
*/ */
function _setConfig(state, { config }) { function _setConfig(state: IVideoQualityState, { config }: { config: IConfig }) {
const configuredMap = config?.videoQuality?.minHeightForQualityLvl; const configuredMap = config?.videoQuality?.minHeightForQualityLvl;
const convertedMap = validateMinHeightForQualityLvl(configuredMap); const convertedMap = validateMinHeightForQualityLvl(configuredMap);

View File

@ -1,9 +1,13 @@
import { ReducerRegistry } from '../base/redux'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { SIP_GW_AVAILABILITY_CHANGED } from './actionTypes'; import { SIP_GW_AVAILABILITY_CHANGED } from './actionTypes';
export interface IVideoSipGW {
status?: string;
}
ReducerRegistry.register( ReducerRegistry.register(
'features/videosipgw', (state = [], action) => { 'features/videosipgw', (state: IVideoSipGW = {}, action): IVideoSipGW => {
switch (action.type) { switch (action.type) {
case SIP_GW_AVAILABILITY_CHANGED: { case SIP_GW_AVAILABILITY_CHANGED: {
return { return {

View File

@ -1,12 +1,19 @@
// @flow import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes'; import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';
import { VIRTUAL_BACKGROUND_TYPE } from './constants'; import { VIRTUAL_BACKGROUND_TYPE } from './constants';
const STORE_NAME = 'features/virtual-background'; const STORE_NAME = 'features/virtual-background';
export interface IVirtualBackground {
backgroundEffectEnabled?: boolean;
backgroundType?: string;
blurValue?: number;
selectedThumbnail?: string;
virtualSource?: string;
}
/** /**
* Reduces redux actions which activate/deactivate virtual background image, or * Reduces redux actions which activate/deactivate virtual background image, or
* indicate if the virtual image background is activated/deactivated. The * indicate if the virtual image background is activated/deactivated. The
@ -18,7 +25,7 @@ const STORE_NAME = 'features/virtual-background';
* @returns {State} The next redux state that is the result of reducing the * @returns {State} The next redux state that is the result of reducing the
* specified action. * specified action.
*/ */
ReducerRegistry.register(STORE_NAME, (state = {}, action) => { ReducerRegistry.register(STORE_NAME, (state: IVirtualBackground = {}, action): IVirtualBackground => {
const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action; const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action;
/** /**