effects for bulk-info is implemented
This commit is contained in:
parent
a201536b02
commit
58ded38772
|
@ -1 +1 @@
|
||||||
Chat
|
<div *ngFor="let room of roomList$ | async">{{ room.finalEventMessage }}</div>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ucapAnimations } from '@ucap-webmessenger/ui';
|
import { ucapAnimations } from '@ucap-webmessenger/ui';
|
||||||
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
import { Store, select } from '@ngrx/store';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||||
|
import * as AppStore from '@app/store';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-layout-chat-left-sidenav-chat',
|
selector: 'app-layout-chat-left-sidenav-chat',
|
||||||
|
@ -8,7 +13,13 @@ import { ucapAnimations } from '@ucap-webmessenger/ui';
|
||||||
animations: ucapAnimations
|
animations: ucapAnimations
|
||||||
})
|
})
|
||||||
export class ChatComponent implements OnInit {
|
export class ChatComponent implements OnInit {
|
||||||
constructor() {}
|
roomList$: Observable<RoomInfo[]>;
|
||||||
|
|
||||||
ngOnInit() {}
|
constructor(private store: Store<any>, private logger: NGXLogger) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.roomList$ = this.store.pipe(
|
||||||
|
select(AppStore.MessengerSelector.SyncSelector.roomList)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ export class AppMessengerResolver implements Resolve<void> {
|
||||||
this.optionProtocolService.regView({})
|
this.optionProtocolService.regView({})
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
tap(([authRes, regViewRes]) => {
|
map(([authRes, regViewRes]) => {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
OptionStore.regViewSuccess({ res: regViewRes })
|
OptionStore.regViewSuccess({ res: regViewRes })
|
||||||
);
|
);
|
||||||
|
@ -139,11 +139,20 @@ export class AppMessengerResolver implements Resolve<void> {
|
||||||
),
|
),
|
||||||
this.store.pipe(
|
this.store.pipe(
|
||||||
select(AppStore.MessengerSelector.SyncSelector.group2SyncDate)
|
select(AppStore.MessengerSelector.SyncSelector.group2SyncDate)
|
||||||
|
),
|
||||||
|
this.store.pipe(
|
||||||
|
select(AppStore.MessengerSelector.SyncSelector.roomSyncDate)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
map(([[], buddy2SyncDate, group2SyncDate]) => {
|
map(([_, buddy2SyncDate, group2SyncDate, roomSyncDate]) => {
|
||||||
this.store.dispatch(SyncStore.buddy2({ syncDate: buddy2SyncDate }));
|
this.store.dispatch(SyncStore.buddy2({ syncDate: buddy2SyncDate }));
|
||||||
this.store.dispatch(SyncStore.group2({ syncDate: group2SyncDate }));
|
this.store.dispatch(SyncStore.group2({ syncDate: group2SyncDate }));
|
||||||
|
this.store.dispatch(
|
||||||
|
SyncStore.room({
|
||||||
|
syncDate: roomSyncDate,
|
||||||
|
localeCode: loginInfo.localeCode
|
||||||
|
})
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
return throwError(err);
|
return throwError(err);
|
||||||
|
@ -156,15 +165,10 @@ export class AppMessengerResolver implements Resolve<void> {
|
||||||
loginInfo: loginRes
|
loginInfo: loginRes
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
console.log('next');
|
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
console.log('err', err);
|
|
||||||
reject(err);
|
reject(err);
|
||||||
},
|
|
||||||
() => {
|
|
||||||
console.log('complete');
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,18 +2,25 @@ import { Type } from '@angular/core';
|
||||||
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
import * as ChatStore from './chat';
|
import * as ChatStore from './chat';
|
||||||
|
import * as StatusStore from './status';
|
||||||
import * as SyncStore from './sync';
|
import * as SyncStore from './sync';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
chat: ChatStore.State;
|
chat: ChatStore.State;
|
||||||
|
status: StatusStore.State;
|
||||||
sync: SyncStore.State;
|
sync: SyncStore.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const effects: Type<any>[] = [ChatStore.Effects, SyncStore.Effects];
|
export const effects: Type<any>[] = [
|
||||||
|
ChatStore.Effects,
|
||||||
|
StatusStore.Effects,
|
||||||
|
SyncStore.Effects
|
||||||
|
];
|
||||||
|
|
||||||
export function reducers(state: State | undefined, action: Action) {
|
export function reducers(state: State | undefined, action: Action) {
|
||||||
return combineReducers({
|
return combineReducers({
|
||||||
chat: ChatStore.reducer,
|
chat: ChatStore.reducer,
|
||||||
|
status: StatusStore.reducer,
|
||||||
sync: SyncStore.reducer
|
sync: SyncStore.reducer
|
||||||
})(state, action);
|
})(state, action);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +33,12 @@ export function selectors<S>(selector: Selector<any, State>) {
|
||||||
(state: State) => state.chat
|
(state: State) => state.chat
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
StatusSelector: StatusStore.selectors(
|
||||||
|
createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.status
|
||||||
|
)
|
||||||
|
),
|
||||||
SyncSelector: SyncStore.selectors(
|
SyncSelector: SyncStore.selectors(
|
||||||
createSelector(
|
createSelector(
|
||||||
selector,
|
selector,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { createAction, props } from '@ngrx/store';
|
||||||
|
import {
|
||||||
|
BulkInfoRequest,
|
||||||
|
StatusBulkInfo
|
||||||
|
} from '@ucap-webmessenger/protocol-status';
|
||||||
|
|
||||||
|
export const bulkInfo = createAction(
|
||||||
|
'[Messenger::Status] Bulk Info',
|
||||||
|
props<BulkInfoRequest>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const bulkInfoSuccess = createAction(
|
||||||
|
'[Messenger::Status] Bulk Info Success',
|
||||||
|
props<{ statusBulkInfoList: StatusBulkInfo[] }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const bulkInfoFailure = createAction(
|
||||||
|
'[Messenger::Status] Bulk Info Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
|
@ -0,0 +1,77 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
import * as SyncStore from '@app/store/messenger/sync';
|
||||||
|
import { bulkInfo, bulkInfoSuccess, bulkInfoFailure } from './actions';
|
||||||
|
import { tap, switchMap, map, catchError } from 'rxjs/operators';
|
||||||
|
import {
|
||||||
|
StatusProtocolService,
|
||||||
|
SSVC_TYPE_STATUS_BULK_INFO_DATA,
|
||||||
|
SSVC_TYPE_STATUS_BULK_INFO_RES,
|
||||||
|
BulkInfoData,
|
||||||
|
StatusBulkInfo
|
||||||
|
} from '@ucap-webmessenger/protocol-status';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class Effects {
|
||||||
|
buddy2SuccessPostBulk$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(SyncStore.buddy2Success),
|
||||||
|
map(params => {
|
||||||
|
const userSeqList: number[] = [];
|
||||||
|
for (const buddy of params.buddyList) {
|
||||||
|
userSeqList.push(buddy.seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bulkInfo({ divCd: 'bulk', userSeqs: userSeqList });
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
bulkInfo$ = createEffect(
|
||||||
|
() => {
|
||||||
|
let statusBulkInfoList: StatusBulkInfo[];
|
||||||
|
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(bulkInfo),
|
||||||
|
tap(() => {
|
||||||
|
statusBulkInfoList = [];
|
||||||
|
}),
|
||||||
|
switchMap(req => {
|
||||||
|
return this.statusProtocolService.bulkInfo(req).pipe(
|
||||||
|
map(res => {
|
||||||
|
switch (res.Type) {
|
||||||
|
case SSVC_TYPE_STATUS_BULK_INFO_DATA:
|
||||||
|
statusBulkInfoList.push(
|
||||||
|
...(res as BulkInfoData).statusBulkInfos
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_STATUS_BULK_INFO_RES:
|
||||||
|
this.store.dispatch(
|
||||||
|
bulkInfoSuccess({
|
||||||
|
statusBulkInfoList
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
catchError(error => of(bulkInfoFailure({ error })))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actions$: Actions,
|
||||||
|
private store: Store<any>,
|
||||||
|
private statusProtocolService: StatusProtocolService,
|
||||||
|
private logger: NGXLogger
|
||||||
|
) {}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './actions';
|
||||||
|
export * from './effects';
|
||||||
|
export * from './reducers';
|
||||||
|
export * from './state';
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { createReducer, on } from '@ngrx/store';
|
||||||
|
import { initialState } from './state';
|
||||||
|
import { bulkInfoSuccess } from './actions';
|
||||||
|
|
||||||
|
export const reducer = createReducer(
|
||||||
|
initialState,
|
||||||
|
on(bulkInfoSuccess, (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
statusBulkInfoList: action.statusBulkInfoList
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
|
import { StatusBulkInfo } from '@ucap-webmessenger/protocol-status';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
statusBulkInfoList: StatusBulkInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialState: State = {
|
||||||
|
statusBulkInfoList: []
|
||||||
|
};
|
||||||
|
|
||||||
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
|
return {
|
||||||
|
statusBulkInfoList: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.statusBulkInfoList
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
|
@ -127,28 +127,28 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
buddy2SuccessPostRoom$ = createEffect(() =>
|
// buddy2SuccessPostRoom$ = createEffect(() =>
|
||||||
this.actions$.pipe(
|
// this.actions$.pipe(
|
||||||
ofType(buddy2Success),
|
// ofType(buddy2Success),
|
||||||
map(action => {
|
// map(action => {
|
||||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
// const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
||||||
KEY_LOGIN_INFO
|
// KEY_LOGIN_INFO
|
||||||
);
|
// );
|
||||||
|
|
||||||
return loginInfo.localeCode;
|
// return loginInfo.localeCode;
|
||||||
}),
|
// }),
|
||||||
withLatestFrom(
|
// withLatestFrom(
|
||||||
this.store.pipe(
|
// this.store.pipe(
|
||||||
select(state => {
|
// select(state => {
|
||||||
return state.messenger.sync.roomSyncDate as string;
|
// return state.messenger.sync.roomSyncDate as string;
|
||||||
})
|
// })
|
||||||
)
|
// )
|
||||||
),
|
// ),
|
||||||
map(([localeCode, roomSyncDate]) =>
|
// map(([localeCode, roomSyncDate]) =>
|
||||||
room({ syncDate: roomSyncDate, localeCode })
|
// room({ syncDate: roomSyncDate, localeCode })
|
||||||
)
|
// )
|
||||||
)
|
// )
|
||||||
);
|
// );
|
||||||
|
|
||||||
room$ = createEffect(
|
room$ = createEffect(
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -17,9 +17,9 @@ import {
|
||||||
} from '../types/terminal-status.type';
|
} from '../types/terminal-status.type';
|
||||||
|
|
||||||
export interface BulkInfoRequest extends ProtocolRequest {
|
export interface BulkInfoRequest extends ProtocolRequest {
|
||||||
// DivCD(s)
|
/** DivCD(s) */
|
||||||
divCd: string;
|
divCd: string;
|
||||||
// 사용자SEQ(n)...
|
/** 사용자SEQ(n)[] */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
export interface StatusBulkInfo extends StatusInfo {
|
export interface StatusBulkInfo extends StatusInfo {
|
||||||
|
@ -32,19 +32,19 @@ export interface StatusBulkInfo extends StatusInfo {
|
||||||
// 상태코드(Mobile화상)
|
// 상태코드(Mobile화상)
|
||||||
// 상태코드(iMessenger)
|
// 상태코드(iMessenger)
|
||||||
|
|
||||||
// 단말상태정보(s)
|
/** 단말상태정보(s) */
|
||||||
terminalStatus: TerminalStatusInfo;
|
terminalStatus: TerminalStatusInfo;
|
||||||
// 단말상태번호(n)
|
/** 단말상태번호(n) */
|
||||||
terminalStatusNumber: TerminalStatusNumber;
|
terminalStatusNumber: TerminalStatusNumber;
|
||||||
}
|
}
|
||||||
export interface BulkInfoData extends ProtocolStream {
|
export interface BulkInfoData extends ProtocolStream {
|
||||||
// DivCD(s)
|
/** DivCD(s) */
|
||||||
divCd: string;
|
divCd: string;
|
||||||
// {상태정보Bulk}...
|
/** {상태정보Bulk}... */
|
||||||
statusBulkInfos: StatusBulkInfo[];
|
statusBulkInfos: StatusBulkInfo[];
|
||||||
}
|
}
|
||||||
export interface BulkInfoResponse extends ProtocolResponse {
|
export interface BulkInfoResponse extends ProtocolResponse {
|
||||||
// DivCD(s)
|
/** DivCD(s) */
|
||||||
divCd: string;
|
divCd: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
encodeBulkInfo,
|
encodeBulkInfo,
|
||||||
decodeBulkInfo,
|
decodeBulkInfo,
|
||||||
decodeBulkInfoData
|
decodeBulkInfoData
|
||||||
} from '../models/bulk';
|
} from '../models/bulk-info';
|
||||||
import { BuddyResponse, decodeBuddy } from '../models/buddy';
|
import { BuddyResponse, decodeBuddy } from '../models/buddy';
|
||||||
import {
|
import {
|
||||||
MessageUpdateRequest,
|
MessageUpdateRequest,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './lib/models/buddy';
|
export * from './lib/models/buddy';
|
||||||
export * from './lib/models/bulk';
|
export * from './lib/models/bulk-info';
|
||||||
export * from './lib/models/message-update';
|
export * from './lib/models/message-update';
|
||||||
export * from './lib/models/status';
|
export * from './lib/models/status';
|
||||||
export * from './lib/models/subscribe';
|
export * from './lib/models/subscribe';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user