bug fixed

This commit is contained in:
richard-loafle 2020-04-03 11:13:46 +09:00
parent d804b01843
commit 46cf9cd253
6 changed files with 44 additions and 22 deletions

8
package-lock.json generated
View File

@ -2378,13 +2378,13 @@
"dev": true
},
"@ucap/ng-store-chat": {
"version": "file:pack/ucap-ng-store-chat-0.0.3.tgz",
"integrity": "sha512-T2MfjHqvP4J1fHJHVE3Mq/CYUnXZh+Uge8hUqDlX5V+KoaH5LUxz56/jX4OCpbwis1Uez+LxeG15IwuYMKZdvg==",
"dev": true
"version": "file:pack/ucap-ng-store-chat-0.0.4.tgz",
"integrity": "sha512-rSZirwFUMv9zXllqBWpdSUbUuRz9j1O8BVIfselp9sZHdKl7Xcx9irqNnHHkF2bJpxeWzugGrgG02tdt/xrIuQ=="
},
"@ucap/ng-store-group": {
"version": "file:pack/ucap-ng-store-group-0.0.5.tgz",
"integrity": "sha512-NNqnSiyQWbBIWLjXsBBxkdCHlRkMPRF8+IXq7scUgG7aNlUA0SGuntUbghRPxAJLQNuMe/csQziOlqHn98sJfw=="
"integrity": "sha512-NNqnSiyQWbBIWLjXsBBxkdCHlRkMPRF8+IXq7scUgG7aNlUA0SGuntUbghRPxAJLQNuMe/csQziOlqHn98sJfw==",
"dev": true
},
"@ucap/ng-store-organization": {
"version": "file:pack/ucap-ng-store-organization-0.0.3.tgz",

View File

@ -166,7 +166,7 @@
"@ucap/ng-protocol-sync": "file:pack/ucap-ng-protocol-sync-0.0.1.tgz",
"@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.4.tgz",
"@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.3.tgz",
"@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.4.tgz",
"@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.5.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",

View File

@ -14,7 +14,8 @@
"@ucap/protocol-room": "@ucap/protocol-room",
"@ucap/protocol-sync": "@ucap/protocol-sync",
"@ucap/ng-protocol-room": "@ucap/ng-protocol-room",
"@ucap/ng-protocol-sync": "@ucap/ng-protocol-sync"
"@ucap/ng-protocol-sync": "@ucap/ng-protocol-sync",
"@ucap/ng-store-authentication": "@ucap/ng-store-authentication"
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@ucap/ng-store-chat",
"version": "0.0.3",
"version": "0.0.4",
"publishConfig": {
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
},
@ -14,6 +14,7 @@
"@ucap/protocol-sync": "~0.0.1",
"@ucap/ng-protocol-room": "~0.0.1",
"@ucap/ng-protocol-sync": "~0.0.1",
"@ucap/ng-store-authentication": "~0.0.1",
"tslib": "^1.10.0"
}
}

View File

@ -2,7 +2,6 @@ import { createAction, props } from '@ngrx/store';
import { LocaleCode } from '@ucap/core';
import { RoomRequest as RoomsRequest } from '@ucap/protocol-sync';
import {
RoomInfo,
UserInfo as RoomUserInfo,
@ -29,7 +28,7 @@ import {
*/
export const rooms = createAction(
'[ucap::chat::room] rooms',
props<{ req: RoomsRequest }>()
props<{ localeCode: LocaleCode }>()
);
/**
* Success of rooms request

View File

@ -1,8 +1,15 @@
import { of } from 'rxjs';
import { catchError, map, switchMap, exhaustMap } from 'rxjs/operators';
import {
catchError,
map,
switchMap,
exhaustMap,
withLatestFrom
} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import {
@ -20,6 +27,10 @@ import { RoomProtocolService } from '@ucap/ng-protocol-room';
import { SyncProtocolService } from '@ucap/ng-protocol-sync';
import { LoginActions } from '@ucap/ng-store-authentication';
import { RoomSelector } from '../state';
import {
rooms,
roomsFailure,
@ -61,21 +72,30 @@ import {
@Injectable()
export class Effects {
postLoginSuccessForRooms$ = createEffect(() => {
return this.actions$.pipe(
ofType(LoginActions.loginSuccess),
map(action => rooms({ localeCode: action.loginSession.localeCode }))
);
});
rooms$ = createEffect(() => {
return this.actions$.pipe(
ofType(rooms),
map(action => action.req),
switchMap(req => {
return this.syncProtocolService.room(req).pipe(
map(res =>
roomsSuccess({
roomList: res.roomList,
roomUserInfoMap: res.roomUserInfoMap,
syncDate: res.res.syncDate
})
),
catchError(error => of(roomsFailure({ error })))
);
withLatestFrom(this.store.pipe(select(RoomSelector.roomsSyncDate))),
switchMap(([action, syncDate]) => {
return this.syncProtocolService
.room({ syncDate, localeCode: action.localeCode })
.pipe(
map(res =>
roomsSuccess({
roomList: res.roomList,
roomUserInfoMap: res.roomUserInfoMap,
syncDate: res.res.syncDate
})
),
catchError(error => of(roomsFailure({ error })))
);
})
);
});
@ -308,6 +328,7 @@ export class Effects {
constructor(
private actions$: Actions,
private store: Store<any>,
private syncProtocolService: SyncProtocolService,
private roomProtocolService: RoomProtocolService
) {}