Compare commits
	
		
			2 Commits
		
	
	
		
			9697e93915
			...
			78e3cf74b9
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					78e3cf74b9 | ||
| 
						 | 
					428353d379 | 
@@ -3,8 +3,8 @@ import { Router } from '@angular/router';
 | 
				
			|||||||
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
 | 
					import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
 | 
				
			||||||
import { Store, Action } from '@ngrx/store';
 | 
					import { Store, Action } from '@ngrx/store';
 | 
				
			||||||
import { Effect, Actions,ofType } from '@ngrx/effects';
 | 
					import { Effect, Actions,ofType } from '@ngrx/effects';
 | 
				
			||||||
import { Observable ,  defer ,  of,from } from 'rxjs';
 | 
					import { Observable ,  defer ,  of,from,zip } from 'rxjs';
 | 
				
			||||||
import { withLatestFrom,mergeMap,switchMap,map,catchError} from 'rxjs/operators';
 | 
					import { withLatestFrom,mergeMap,switchMap,map,catchError,first} from 'rxjs/operators';
 | 
				
			||||||
import * as appCommonActions from '../actions/app-common.actions';
 | 
					import * as appCommonActions from '../actions/app-common.actions';
 | 
				
			||||||
import * as appCommonReducers from '../reducers/app-common.reducer';
 | 
					import * as appCommonReducers from '../reducers/app-common.reducer';
 | 
				
			||||||
import { ItemService } from '../services/item.service';
 | 
					import { ItemService } from '../services/item.service';
 | 
				
			||||||
@@ -50,16 +50,11 @@ export class AppCommonEffects {
 | 
				
			|||||||
  @Effect()
 | 
					  @Effect()
 | 
				
			||||||
  initUser$: Observable<Action> = this.actions$.pipe(
 | 
					  initUser$: Observable<Action> = this.actions$.pipe(
 | 
				
			||||||
    ofType(appCommonActions.INITUSER),
 | 
					    ofType(appCommonActions.INITUSER),
 | 
				
			||||||
    withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
 | 
					    first(),
 | 
				
			||||||
    switchMap(([action, initialized]) => {
 | 
					    switchMap((action) => {
 | 
				
			||||||
      if(!initialized) {       
 | 
					        return zip(this.userService$.getCurrentUser(),from(this.oauthService$.loadUserProfile())).pipe(
 | 
				
			||||||
      return this.userService$.getCurrentUser().pipe(
 | 
					 | 
				
			||||||
        withLatestFrom(from(this.oauthService$.loadUserProfile())),
 | 
					 | 
				
			||||||
        switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
 | 
					        switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
 | 
				
			||||||
        catchError(error => of(new appCommonActions.Fail(error))))
 | 
					        catchError(error => of(new appCommonActions.Fail(error))))
 | 
				
			||||||
      } else {
 | 
					 | 
				
			||||||
        return [];
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  ));
 | 
					  ));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,9 @@ export const initialState: State = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function reducer(state = initialState, action: appCommonActions.Actions ): State {
 | 
					export function reducer(state = initialState, action: appCommonActions.Actions ): State {
 | 
				
			||||||
  switch (action.type) {
 | 
					  switch (action.type) {
 | 
				
			||||||
 | 
					    case appCommonActions.INITUSER: {
 | 
				
			||||||
 | 
					      return tassign(state,{initialized: true});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    case appCommonActions.INITUSERSUCCESS: {
 | 
					    case appCommonActions.INITUSERSUCCESS: {
 | 
				
			||||||
      let a = action as appCommonActions.InitUserSuccess;
 | 
					      let a = action as appCommonActions.InitUserSuccess;
 | 
				
			||||||
      let claims = {}
 | 
					      let claims = {}
 | 
				
			||||||
@@ -50,7 +53,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
 | 
				
			|||||||
        name:a.userinfo["name"],
 | 
					        name:a.userinfo["name"],
 | 
				
			||||||
        claims:claims
 | 
					        claims:claims
 | 
				
			||||||
      };     
 | 
					      };     
 | 
				
			||||||
      return tassign(state, { user: user,initialized: true });
 | 
					      return tassign(state, { user: user });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case appCommonActions.INITROOTSUCCESS: {
 | 
					    case appCommonActions.INITROOTSUCCESS: {
 | 
				
			||||||
      let a = action as appCommonActions.InitRootSuccess;
 | 
					      let a = action as appCommonActions.InitRootSuccess;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user