diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts index b584b7c..985f254 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ b/projects/common-map/src/fm-map/components/map/map.component.ts @@ -181,19 +181,20 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { newQueryState = tassign(mapReducers.initialQueryState); if (queryState != "") { newQueryState = this.serializeService.deserialize(queryState); + queryState = this.serializeService.serialize(newQueryState); } - queryStateChanged = this.lastQueryState != queryState; + queryStateChanged = this.lastQueryState != queryState; this.lastQueryState = queryState; } if (mapStateChanged && queryStateChanged) { - //console.log("Both states"); + console.debug("Both states"); this.store.dispatch(new mapActions.SetState(newMapState, newQueryState)); } else if (mapStateChanged) { - //console.log("Map state"); + console.debug("Map state"); this.store.dispatch(new mapActions.SetMapState(newMapState)); } else if (queryStateChanged) { - //console.log("Query state"); + console.debug("Query state"); this.store.dispatch(new mapActions.SetQueryState(newQueryState)); } this.stateSetCount += 1; diff --git a/projects/common/src/fm/actions/app-common.actions.ts b/projects/common/src/fm/actions/app-common.actions.ts index d982659..f7ac6e8 100644 --- a/projects/common/src/fm/actions/app-common.actions.ts +++ b/projects/common/src/fm/actions/app-common.actions.ts @@ -13,7 +13,6 @@ export const INITROOTSUCCESS = '[Explorer] InitRootSuccess'; export const OPENMODAL = '[AppCommon] OpenModal'; export const CLOSEMODAL = '[AppCommon] CloseModal'; export const LOGIN = '[AppCommon] Login'; -export const INITIALIZED = '[AppCommon] Initialized'; export const ESCAPE = '[AppCommon] Escape'; export const LOADITEMTYPES = '[AppCommon] LoadItemTypes'; @@ -104,12 +103,6 @@ export class Login implements Action { constructor(public url: string) { } } -export class Initialized implements Action { - readonly type = INITIALIZED; - - constructor() { } -} - export class Escape implements Action { readonly type = ESCAPE; @@ -235,7 +228,6 @@ export type Actions = OpenModal | InitRootSuccess | CloseModal | Login - | Initialized | ItemChangedEvent | ItemAddedEvent | ItemDeletedEvent diff --git a/projects/common/src/fm/effects/app-common.effects.ts b/projects/common/src/fm/effects/app-common.effects.ts index cc974dd..701b07a 100644 --- a/projects/common/src/fm/effects/app-common.effects.ts +++ b/projects/common/src/fm/effects/app-common.effects.ts @@ -40,10 +40,15 @@ export class AppCommonEffects { @Effect() initUser$: Observable = this.actions$.pipe( ofType(appCommonActions.INITUSER), - switchMap(() => { + withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)), + switchMap(([action, initialized]) => { + if(!initialized) { return this.userService$.getCurrentUser().pipe( map((user: IUser) => new appCommonActions.InitUserSuccess(user)), catchError(error => of(new appCommonActions.Fail(error)))) + } else { + return []; + } } )); diff --git a/projects/common/src/fm/reducers/app-common.reducer.ts b/projects/common/src/fm/reducers/app-common.reducer.ts index e97cc05..f8ba4ca 100644 --- a/projects/common/src/fm/reducers/app-common.reducer.ts +++ b/projects/common/src/fm/reducers/app-common.reducer.ts @@ -33,7 +33,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) switch (action.type) { case appCommonActions.INITUSERSUCCESS: { let a = action as appCommonActions.InitUserSuccess; - return tassign(state, { user: a.user }); + return tassign(state, { user: a.user,initialized: true }); } case appCommonActions.INITROOTSUCCESS: { let a = action as appCommonActions.InitRootSuccess; @@ -44,10 +44,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) } case appCommonActions.CLOSEMODAL: { return tassign(state, { openedModalName: null }); - } - case appCommonActions.INITIALIZED: { - return tassign(state, { initialized: true }); - } + } case appCommonActions.LOADITEMTYPESSUCCESS: { let a = action as appCommonActions.LoadItemTypesSuccess; return tassign(state, { itemTypes: a.itemTypes }); diff --git a/projects/common/src/fm/services/auth-guard.service.ts b/projects/common/src/fm/services/auth-guard.service.ts index 089fa9a..578e767 100644 --- a/projects/common/src/fm/services/auth-guard.service.ts +++ b/projects/common/src/fm/services/auth-guard.service.ts @@ -18,8 +18,6 @@ import * as appCommonActions from '../actions/app-common.actions'; }) export class AuthGuard implements CanActivate, CanLoad, CanActivateChild { - private loginDispatched = false; - private initialized = false; constructor(private oauthService: OAuthService, private router: Router, private store: Store ) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {