Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 4x 4x 3x 3x 1x | import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Store, select } from '@ngrx/store';
import { map, switchMap, take } from 'rxjs/operators';
import { whenFalsy } from 'ish-core/utils/operators';
import { StatePropertiesService } from 'ish-core/utils/state-transfer/state-properties.service';
import { CopilotConfig } from '../../models/copilot-config/copilot-config.model';
import { copilotConfigInternalActions } from './copilot-config.actions';
import { getCopilotConfig } from './copilot-config.selectors';
@Injectable()
export class CopilotConfigEffects {
constructor(
private actions$: Actions,
private store: Store,
private statePropertiesService: StatePropertiesService
) {}
loadCopilotConfiguration$ = createEffect(() =>
this.actions$.pipe(
ofType(copilotConfigInternalActions.loadCopilotConfig),
switchMap(() =>
this.statePropertiesService.getStateOrEnvOrDefault<CopilotConfig>('COPILOT', 'copilot').pipe(
// make sure to trigger the set action only once (was triggered twice for some reason)
take(1),
map(config => copilotConfigInternalActions.setCopilotConfig({ config }))
)
)
)
);
loadCopilotConfigOnInit$ = createEffect(() =>
this.store.pipe(
select(getCopilotConfig),
whenFalsy(),
map(() => copilotConfigInternalActions.loadCopilotConfig())
)
);
}
|