AW-1419
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good Details

2022.01
Willem Dantuma 2020-08-04 16:09:22 +02:00
parent 309b320534
commit ee7d1cb9a2
2 changed files with 26 additions and 6 deletions

View File

@ -74,6 +74,12 @@ export class InitUserSuccess implements Action {
constructor(public user:IUser,public userinfo:UserInfo ) { }
}
export class InitUserPackages implements Action {
readonly type = INITUSERPACKAGES;
constructor() {}
}
export class InitUserPackagesSuccess implements Action {
readonly type = INITUSERPACKAGESSUCCESS;
@ -301,6 +307,7 @@ export type Actions = OpenModal
| DeviceUpdateEvent
| ToggleMenu
| SetMenuVisible
| InitUserPackages
| InitUserPackagesSuccess
| ToggleAccountMenu
| CloseAll

View File

@ -57,24 +57,37 @@ export class AppCommonEffects {
catchError(error => of(new appCommonActions.Fail(error))))
}
));
@Effect()
initUserPackages$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS),
switchMap((action) => {
let a = action as appCommonActions.InitUserSuccess;
return this.itemService$.getChildItemList(a.user.code+":USER_PACKAGES","vnd.farmmaps.itemtype.package").pipe(
ofType(appCommonActions.INITUSERPACKAGES),
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
switchMap(([action,user]) => {
return this.itemService$.getChildItemList(user.code+":USER_PACKAGES","vnd.farmmaps.itemtype.package").pipe(
switchMap((items) => of(new appCommonActions.InitUserPackagesSuccess(items))),
catchError(error => of(new appCommonActions.Fail(error)))
)
})
);
@Effect()
userPackagesChanged$:Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
if(a.itemCode.endsWith(":USER_PACKAGES"))
return of(new appCommonActions.InitUserPackages());
else
return of(undefined);
})
);
@Effect()
initUserSuccess$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS),
switchMap(() => {
return of(new appCommonActions.InitRoot());
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages()];
}
));