2020-01-28 10:06:03 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import { createScreenshotCaptureEffect } from '../../stream-effects/screenshot-capture';
|
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();
|
|
|
|
const screenshotCapturePromise = state['features/screenshot-capture']?.capturesEnabled
|
|
|
|
? createScreenshotCaptureEffect(state)
|
|
|
|
.catch(error => {
|
|
|
|
logger.error('Failed to obtain the screenshot capture effect effect instance with error: ', error);
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
})
|
|
|
|
: Promise.resolve();
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
return Promise.all([ backgroundPromise, screenshotCapturePromise ]);
|
2020-01-28 10:06:03 +00:00
|
|
|
}
|