2023-02-02 11:12:31 +00:00
|
|
|
import { IStore } from '../../app/types';
|
|
|
|
// eslint-disable-next-line lines-around-comment
|
|
|
|
// @ts-ignore
|
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.
|
|
|
|
*/
|
2023-02-02 11:12:31 +00:00
|
|
|
export default function loadEffects(store: IStore): Promise<any> {
|
2020-01-28 10:06:03 +00:00
|
|
|
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)
|
2023-02-02 11:12:31 +00:00
|
|
|
.catch((error: 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
|
|
|
}
|