diff --git a/package-lock.json b/package-lock.json index 9832026..c0f1add 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2378,7 +2378,8 @@ }, "@ucap/ng-store-authentication": { "version": "file:pack/ucap-ng-store-authentication-0.0.3.tgz", - "integrity": "sha512-qgtPOxPDBWLytKNl4KxPJiAt+EhWk+7JZMiKGlrs/VqXgys4UHVv/OJhOC46d0ZBunswUsiEw4W97NXi+APW/w==" + "integrity": "sha512-qgtPOxPDBWLytKNl4KxPJiAt+EhWk+7JZMiKGlrs/VqXgys4UHVv/OJhOC46d0ZBunswUsiEw4W97NXi+APW/w==", + "dev": true }, "@ucap/ng-store-chat": { "version": "file:pack/ucap-ng-store-chat-0.0.3.tgz", @@ -2386,9 +2387,8 @@ "dev": true }, "@ucap/ng-store-group": { - "version": "file:pack/ucap-ng-store-group-0.0.3.tgz", - "integrity": "sha512-S/uognL5t0N5yQSoLOKHnvE01158wmP10p70Swfues9o88Ct55ABFOggDFdNcrHd9K7ei6S+objl3hIq/kg42w==", - "dev": true + "version": "file:pack/ucap-ng-store-group-0.0.4.tgz", + "integrity": "sha512-UTvyFws2Gl+yFAIAj76oHhsJHowH0sgZFtdNeLRYouB970z1yqUsPLczyZTH6INEukBclANwEzeZxM2+SaeiUg==" }, "@ucap/ng-store-organization": { "version": "file:pack/ucap-ng-store-organization-0.0.3.tgz", diff --git a/package.json b/package.json index 9ae4ed0..68a55bb 100644 --- a/package.json +++ b/package.json @@ -167,7 +167,7 @@ "@ucap/ng-protocol-umg": "file:pack/ucap-ng-protocol-umg-0.0.1.tgz", "@ucap/ng-store-authentication": "file:pack/ucap-ng-store-authentication-0.0.3.tgz", "@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.3.tgz", - "@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.3.tgz", + "@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.4.tgz", "@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.3.tgz", "@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.3.tgz", "@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.14.tgz", diff --git a/projects/store-group/ng-package.json b/projects/store-group/ng-package.json index 8f8e739..4396113 100644 --- a/projects/store-group/ng-package.json +++ b/projects/store-group/ng-package.json @@ -17,7 +17,8 @@ "@ucap/ng-protocol-buddy": "@ucap/ng-protocol-buddy", "@ucap/ng-protocol-group": "@ucap/ng-protocol-group", "@ucap/ng-protocol-sync": "@ucap/ng-protocol-sync", - "@ucap/ng-store-organization": "@ucap/ng-store-organization" + "@ucap/ng-store-organization": "@ucap/ng-store-organization", + "@ucap/ng-store-authentication": "@ucap/ng-store-authentication" } } } diff --git a/projects/store-group/package.json b/projects/store-group/package.json index 71e7ed2..0e738f8 100644 --- a/projects/store-group/package.json +++ b/projects/store-group/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-store-group", - "version": "0.0.3", + "version": "0.0.4", "publishConfig": { "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" }, @@ -16,6 +16,7 @@ "@ucap/ng-protocol-group": "~0.0.1", "@ucap/ng-protocol-sync": "~0.0.1", "@ucap/ng-store-organization": "~0.0.1", + "@ucap/ng-store-authentication": "~0.0.1", "tslib": "^1.10.0" } } diff --git a/projects/store-group/src/lib/store/buddy/actions.ts b/projects/store-group/src/lib/store/buddy/actions.ts index bea95e3..6530c4b 100644 --- a/projects/store-group/src/lib/store/buddy/actions.ts +++ b/projects/store-group/src/lib/store/buddy/actions.ts @@ -1,5 +1,5 @@ import { createAction, props } from '@ngrx/store'; -import { BuddyRequest, UserInfo } from '@ucap/protocol-sync'; +import { UserInfo } from '@ucap/protocol-sync'; import { AddRequest as BuddyAddRequest, @@ -13,10 +13,7 @@ import { /** * retrieve list of buddy */ -export const buddy2 = createAction( - '[ucap::group::buddy] buddy2', - props<{ req: BuddyRequest }>() -); +export const buddy2 = createAction('[ucap::group::buddy] buddy2'); /** * Success of buddy2 request */ diff --git a/projects/store-group/src/lib/store/buddy/effects.ts b/projects/store-group/src/lib/store/buddy/effects.ts index 0bcf468..fc12bae 100644 --- a/projects/store-group/src/lib/store/buddy/effects.ts +++ b/projects/store-group/src/lib/store/buddy/effects.ts @@ -11,24 +11,20 @@ import { import { Injectable, Inject } from '@angular/core'; import { Store, select } from '@ngrx/store'; -import { Dictionary } from '@ngrx/entity'; import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { GroupDetailData } from '@ucap/protocol-sync'; - import { AddResponse as BuddyAddResponse, DelResponse as BuddyDelResponse, UpdateResponse as BuddyUpdateResponse } from '@ucap/protocol-buddy'; -import { UserInfoSS } from '@ucap/protocol-query'; - import { SyncProtocolService } from '@ucap/ng-protocol-sync'; import { BuddyProtocolService } from '@ucap/ng-protocol-buddy'; import { DepartmentSelector } from '@ucap/ng-store-organization'; +import { LoginActions } from '@ucap/ng-store-authentication'; import * as groupActions from '../group/actions'; @@ -54,12 +50,20 @@ import { _MODULE_CONFIG } from '../../config/token'; @Injectable() export class Effects { + postLoginSuccessForBuddy2$ = createEffect(() => { + return this.actions$.pipe( + ofType(LoginActions.loginSuccess), + map(action => action.loginRes), + map(req => buddy2()) + ); + }); + buddy2$ = createEffect(() => { return this.actions$.pipe( ofType(buddy2), - map(action => action.req), - switchMap(req => { - return this.syncProtocolService.buddy2(req).pipe( + withLatestFrom(this.store.pipe(select(BuddySelector.buddySyncDate))), + switchMap(([action, syncDate]) => { + return this.syncProtocolService.buddy2({ syncDate }).pipe( map(res => buddy2Success({ buddyList: res.buddyInfos, @@ -76,15 +80,10 @@ export class Effects { this.actions$.pipe( ofType(add), map(action => action.req), - withLatestFrom(this.store.pipe(select(BuddySelector.buddySyncDate))), - exhaustMap(([req, syncDate]) => + exhaustMap(req => this.buddyProtocolService.add(req).pipe( map((res: BuddyAddResponse) => { - return buddy2({ - req: { - syncDate - } - }); + return buddy2(); }), catchError(error => of(addFailure({ error }))) ) diff --git a/projects/store-group/src/lib/store/group/actions.ts b/projects/store-group/src/lib/store/group/actions.ts index 5025277..fb84ac2 100644 --- a/projects/store-group/src/lib/store/group/actions.ts +++ b/projects/store-group/src/lib/store/group/actions.ts @@ -11,10 +11,7 @@ import { /** * retrieve list of group */ -export const groups = createAction( - '[ucap::group::group] groups', - props<{ req: GroupRequest }>() -); +export const groups = createAction('[ucap::group::group] groups'); /** * Success of groups request */ diff --git a/projects/store-group/src/lib/store/group/effects.ts b/projects/store-group/src/lib/store/group/effects.ts index 3cead2c..03c6ce3 100644 --- a/projects/store-group/src/lib/store/group/effects.ts +++ b/projects/store-group/src/lib/store/group/effects.ts @@ -24,6 +24,7 @@ import { GroupProtocolService } from '@ucap/ng-protocol-group'; import { SyncProtocolService } from '@ucap/ng-protocol-sync'; import { DepartmentSelector } from '@ucap/ng-store-organization'; +import { LoginActions } from '@ucap/ng-store-authentication'; import { ModuleConfig } from '../../config/module-config'; import { _MODULE_CONFIG } from '../../config/token'; @@ -53,12 +54,20 @@ import { @Injectable() export class Effects { + postLoginSuccessForGroups$ = createEffect(() => { + return this.actions$.pipe( + ofType(LoginActions.loginSuccess), + map(action => action.loginRes), + map(req => groups()) + ); + }); + groups$ = createEffect(() => { return this.actions$.pipe( ofType(groups), - map(action => action.req), - concatMap(req => { - return this.syncProtocolService.group2(req).pipe( + withLatestFrom(this.store.pipe(select(GroupSelector.groupSyncDate))), + switchMap(([action, syncDate]) => { + return this.syncProtocolService.group2({ syncDate }).pipe( map(res => groupsSuccess({ groupList: res.groupInfos, @@ -173,11 +182,8 @@ export class Effects { moveMember$ = createEffect(() => this.actions$.pipe( ofType(moveMember), - withLatestFrom( - this.store.pipe(select(GroupSelector.groups)), - this.store.pipe(select(GroupSelector.groupSyncDate)) - ), - exhaustMap(([action, groupList, syncDate]) => { + withLatestFrom(this.store.pipe(select(GroupSelector.groups))), + exhaustMap(([action, groupList]) => { // copy to const toGroup = groupList.find(g => g.seq === action.toGroup.seq); @@ -215,11 +221,7 @@ export class Effects { }) .pipe( map((resFrom: GroupUpdateResponse) => { - return groups({ - req: { - syncDate - } - }); + return groups(); }), catchError(error => of(moveFromFailure({ error }))) ); @@ -305,15 +307,10 @@ export class Effects { this.actions$.pipe( ofType(update), map(action => action.req), - withLatestFrom(this.store.pipe(select(GroupSelector.groupSyncDate))), - concatMap(([req, syncDate]) => + concatMap(req => this.groupProtocolService.update2(req).pipe( map((res: GroupUpdateResponse) => { - return groups({ - req: { - syncDate - } - }); + return groups(); }), catchError(error => of(updateFailure({ error }))) )