AW-1431 Add InitUserSettingsRoot
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
2020-08-13 13:06:28 +02:00
parent ad1d40cdd1
commit 4d67a656f5
3 changed files with 49 additions and 1 deletions

View File

@@ -81,12 +81,36 @@ export class AppCommonEffects {
return [];
})
);
@Effect()
initUserSettingsRoot$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSETTINGSROOT),
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
switchMap(([, user]) => {
return this.itemService$.getItem(user.code + ':USER_SETTINGS').pipe(
switchMap((item) => of(new appCommonActions.InitUserSettingsRootSuccess(item))),
catchError(error => of(new appCommonActions.Fail(error)))
)
})
);
@Effect()
initUserSettingsRootChanged$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
if(a.itemCode.endsWith(":USER_SETTINGS"))
return of(new appCommonActions.InitUserSettingsRoot());
else
return [];
})
);
@Effect()
initUserSuccess$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS),
switchMap(() => {
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages()];
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages(),new appCommonActions.InitUserSettingsRoot()];
}
));