2020-01-28 10:06:03 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-03-12 15:50:57 +00:00
|
|
|
import { createVirtualBackgroundEffect } from '../../stream-effects/virtual-background';
|
2020-01-28 10:06:03 +00:00
|
|
|
|
|
|
|
import logger from './logger';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the enabled stream effects.
|
|
|
|
*
|
|
|
|
* @param {Object} store - The Redux store.
|
|
|
|
* @returns {Promsie} - A Promise which resolves when all effects are created.
|
|
|
|
*/
|
|
|
|
export default function loadEffects(store: Object): Promise<any> {
|
|
|
|
const state = store.getState();
|
2021-03-12 15:50:57 +00:00
|
|
|
const virtualBackground = state['features/virtual-background'];
|
2020-01-28 10:06:03 +00:00
|
|
|
|
2021-03-12 15:50:57 +00:00
|
|
|
const backgroundPromise = virtualBackground.backgroundEffectEnabled
|
|
|
|
? createVirtualBackgroundEffect(virtualBackground)
|
2020-01-28 10:06:03 +00:00
|
|
|
.catch(error => {
|
2021-02-18 15:52:47 +00:00
|
|
|
logger.error('Failed to obtain the background effect instance with error: ', error);
|
2020-01-28 10:06:03 +00:00
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
})
|
|
|
|
: Promise.resolve();
|
|
|
|
|
2021-07-26 11:38:56 +00:00
|
|
|
return Promise.all([ backgroundPromise ]);
|
2020-01-28 10:06:03 +00:00
|
|
|
}
|