From 638f41d26f3c957423b9538ad2650cdd2ef9af20 Mon Sep 17 00:00:00 2001 From: richard-loafle <44828666+richard-loafle@users.noreply.github.com> Date: Fri, 3 Apr 2020 16:44:28 +0900 Subject: [PATCH] bug fixed --- package-lock.json | 6 ++-- package.json | 2 +- .../resolvers/app-authentication.resolver.ts | 13 +++++--- src/app/store/app/actions.ts | 33 +------------------ src/app/store/app/reducers.ts | 23 +------------ src/app/store/app/state.ts | 24 ++------------ src/app/store/effects.ts | 5 +-- src/app/store/reducers.ts | 8 +++-- src/app/store/state.ts | 6 ++-- 9 files changed, 29 insertions(+), 91 deletions(-) diff --git a/package-lock.json b/package-lock.json index daf574d..6c1f5cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1926,9 +1926,9 @@ "integrity": "sha512-JnILmpoqUc8zQKZqbucBJ2H68y3Oy7HB4h/Ax6bq4Ctqxk6qaA2/Eda65WTS8L4EresYdVGW07AR4Z0p0XLIzg==" }, "@ucap/ng-store-authentication": { - "version": "0.0.6", - "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/ng-store-authentication/-/ng-store-authentication-0.0.6.tgz", - "integrity": "sha512-qP3+rsni/z/JOTR/VPjH+09buvHphJc4IHMSS+HlAFvJPeLcWXWChANzpUG3tWNxEbrh8GhaOlzYkGyqBJTVLA==" + "version": "0.0.7", + "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/ng-store-authentication/-/ng-store-authentication-0.0.7.tgz", + "integrity": "sha512-6IxxjFYpmN3xC2zIix9BfXbHHKpZeeS09SlT7RujMGt58CPyLnWkCFa/a4NILYQpUaXwQn+CmB1o8nhaZvwMNw==" }, "@ucap/ng-store-chat": { "version": "0.0.4", diff --git a/package.json b/package.json index e3c5da3..8b13b86 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@ucap/ng-protocol-status": "~0.0.2", "@ucap/ng-protocol-sync": "~0.0.2", "@ucap/ng-protocol-umg": "~0.0.2", - "@ucap/ng-store-authentication": "~0.0.6", + "@ucap/ng-store-authentication": "~0.0.7", "@ucap/ng-store-chat": "~0.0.4", "@ucap/ng-store-group": "~0.0.5", "@ucap/ng-store-organization": "~0.0.3", diff --git a/src/app/resolvers/app-authentication.resolver.ts b/src/app/resolvers/app-authentication.resolver.ts index 3dde83e..41df4c8 100644 --- a/src/app/resolvers/app-authentication.resolver.ts +++ b/src/app/resolvers/app-authentication.resolver.ts @@ -25,7 +25,10 @@ import { QueryProtocolService } from '@ucap/ng-protocol-query'; import { OptionProtocolService } from '@ucap/ng-protocol-option'; import { CompanyActions } from '@ucap/ng-store-organization'; -import { LoginActions } from '@ucap/ng-store-authentication'; +import { + ConfigurationActions, + LoginActions +} from '@ucap/ng-store-authentication'; import { LoginSession } from '@app/models/login-session'; import { AppKey } from '@app/types/app-key.type'; @@ -100,7 +103,7 @@ export class AppAuthenticationResolver implements Resolve { ) { if (StatusCode.Fail === versionInfo2Res.statusCode) { this.store.dispatch( - AppActions.versionInfo2Failure({ + ConfigurationActions.versionInfo2Failure({ error: versionInfo2Res.errorMessage }) ); @@ -110,7 +113,7 @@ export class AppAuthenticationResolver implements Resolve { if (StatusCode.Fail === urlInfoRes.statusCode) { this.store.dispatch( - AppActions.urlInfoFailure({ + ConfigurationActions.urlInfoFailure({ error: urlInfoRes.errorMessage }) ); @@ -122,13 +125,13 @@ export class AppAuthenticationResolver implements Resolve { } this.store.dispatch( - AppActions.versionInfo2Success({ + ConfigurationActions.versionInfo2Success({ res: versionInfo2Res }) ); this.store.dispatch( - AppActions.urlInfoSuccess({ + ConfigurationActions.urlInfoSuccess({ res: urlInfoRes }) ); diff --git a/src/app/store/app/actions.ts b/src/app/store/app/actions.ts index b2aba68..a137c99 100644 --- a/src/app/store/app/actions.ts +++ b/src/app/store/app/actions.ts @@ -1,34 +1,3 @@ import { createAction, props } from '@ngrx/store'; -import { VersionInfo2Response, VersionInfo2Request } from '@ucap/api-public'; -import { UrlInfoRequest, UrlInfoResponse } from '@ucap/api-external'; - -export const versionInfo2 = createAction( - '[ucap::app::app] versionInfo2', - props<{ req: VersionInfo2Request }>() -); - -export const versionInfo2Success = createAction( - '[ucap::app::app] versionInfo2 Success', - props<{ res: VersionInfo2Response }>() -); - -export const versionInfo2Failure = createAction( - '[ucap::app::app] versionInfo2 Failure', - props<{ error: any }>() -); - -export const urlInfo = createAction( - '[ucap::app::app] urlInfo', - props<{ req: UrlInfoRequest }>() -); - -export const urlInfoSuccess = createAction( - '[ucap::app::app] urlInfo Success', - props<{ res: UrlInfoResponse }>() -); - -export const urlInfoFailure = createAction( - '[ucap::app::app] urlInfo Failure', - props<{ error: any }>() -); +export const init = createAction('[ucap::LG::app] init'); diff --git a/src/app/store/app/reducers.ts b/src/app/store/app/reducers.ts index 3bafb90..70e7e20 100644 --- a/src/app/store/app/reducers.ts +++ b/src/app/store/app/reducers.ts @@ -1,25 +1,4 @@ import { createReducer, on } from '@ngrx/store'; import { initialState } from './state'; -import { versionInfo2Success, urlInfoSuccess } from './actions'; -export const reducer = createReducer( - initialState, - on(versionInfo2Success, (state, action) => { - return { - ...state, - versionInfo2Response: { - ...state.versionInfo2Response, - ...action.res - } - }; - }), - on(urlInfoSuccess, (state, action) => { - return { - ...state, - urlInfoResponse: { - ...state.urlInfoResponse, - ...action.res - } - }; - }) -); +export const reducer = createReducer(initialState); diff --git a/src/app/store/app/state.ts b/src/app/store/app/state.ts index 756126c..1e05bd0 100644 --- a/src/app/store/app/state.ts +++ b/src/app/store/app/state.ts @@ -1,27 +1,9 @@ import { Selector, createSelector } from '@ngrx/store'; -import { VersionInfo2Response } from '@ucap/api-public'; -import { UrlInfoResponse } from '@ucap/api-external'; +export interface State {} -export interface State { - versionInfo2Response: VersionInfo2Response | null; - urlInfoResponse: UrlInfoResponse | null; -} - -export const initialState: State = { - versionInfo2Response: null, - urlInfoResponse: null -}; +export const initialState: State = {}; export function selectors(selector: Selector) { - return { - versionInfo2Response: createSelector( - selector, - (state: State) => state.versionInfo2Response - ), - urlInfoResponse: createSelector( - selector, - (state: State) => state.urlInfoResponse - ) - }; + return {}; } diff --git a/src/app/store/effects.ts b/src/app/store/effects.ts index d087ede..a92aa2d 100644 --- a/src/app/store/effects.ts +++ b/src/app/store/effects.ts @@ -1,5 +1,6 @@ import { Type } from '@angular/core'; -import { Effects as AuthenticationEffects } from './authentication/effects'; +import { Effects as AppEffects } from './app/effects'; +import { Effects as AppAuthenticationEffects } from './authentication/effects'; -export const effects: Type[] = [AuthenticationEffects]; +export const effects: Type[] = [AppEffects, AppAuthenticationEffects]; diff --git a/src/app/store/reducers.ts b/src/app/store/reducers.ts index 0a0f026..75a182f 100644 --- a/src/app/store/reducers.ts +++ b/src/app/store/reducers.ts @@ -1,17 +1,19 @@ import { InjectionToken } from '@angular/core'; -import { combineReducers, Action, ActionReducerMap } from '@ngrx/store'; +import { Action, ActionReducerMap } from '@ngrx/store'; import * as fromRouter from '@ngrx/router-store'; import { State } from './state'; -import { reducer as authenticationReducer } from './authentication/reducers'; +import { reducer as appReducer } from './app/reducers'; +import { reducer as appAuthenticationReducer } from './authentication/reducers'; export const ROOT_REDUCERS = new InjectionToken< ActionReducerMap >('Root reducers token', { factory: () => ({ appRouter: fromRouter.routerReducer, - appAuthentication: authenticationReducer + app: appReducer, + appAuthentication: appAuthenticationReducer }) }); diff --git a/src/app/store/state.ts b/src/app/store/state.ts index f39e4ae..eec17da 100644 --- a/src/app/store/state.ts +++ b/src/app/store/state.ts @@ -8,11 +8,13 @@ import * as fromRouter from '@ngrx/router-store'; import { environment } from '@environments'; -import { State as AuthenticationState } from './authentication/state'; +import { State as AppState } from './app/state'; +import { State as AppAuthenticationState } from './authentication/state'; export interface State { appRouter: fromRouter.RouterReducerState; - appAuthentication: AuthenticationState; + app: AppState; + appAuthentication: AppAuthenticationState; } export const metaReducers: MetaReducer[] = !environment.production