2021-02-18 15:52:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-03-30 21:27:44 +00:00
|
|
|
import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
|
|
|
import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';
|
2021-05-26 11:53:14 +00:00
|
|
|
import { VIRTUAL_BACKGROUND_TYPE } from './constants';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-03-30 21:27:44 +00:00
|
|
|
const STORE_NAME = 'features/virtual-background';
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
/**
|
|
|
|
* Reduces redux actions which activate/deactivate virtual background image, or
|
|
|
|
* indicate if the virtual image background is activated/deactivated. The
|
|
|
|
* backgroundEffectEnabled flag indicate if virtual background effect is activated.
|
|
|
|
*
|
|
|
|
* @param {State} 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.
|
|
|
|
*/
|
2021-03-30 21:27:44 +00:00
|
|
|
ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
|
2021-04-09 14:25:26 +00:00
|
|
|
const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action;
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-05-13 14:38:23 +00:00
|
|
|
/**
|
|
|
|
* Sets up the persistence of the feature {@code virtual-background}.
|
|
|
|
*/
|
2021-05-26 11:53:14 +00:00
|
|
|
PersistenceRegistry.register(STORE_NAME, state.backgroundType !== VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE);
|
2021-05-13 14:38:23 +00:00
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SET_VIRTUAL_BACKGROUND: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
virtualSource,
|
2021-04-09 12:17:06 +00:00
|
|
|
blurValue,
|
2021-04-09 14:25:26 +00:00
|
|
|
backgroundType,
|
|
|
|
selectedThumbnail
|
2021-02-18 15:52:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
case BACKGROUND_ENABLED: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
backgroundEffectEnabled
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|