From c7a7f6ca23f54324b8b032f56582d81613c83aab Mon Sep 17 00:00:00 2001 From: leejh Date: Mon, 4 Nov 2019 11:36:58 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B8=B0=20::=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=20=EC=83=81=EB=8C=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/messages.component.ts | 42 ++++++------- .../chat/create-chat.dialog.component.html | 15 +++-- .../chat/create-chat.dialog.component.ts | 40 +++++++++++- .../src/app/store/messenger/room/actions.ts | 17 ++++- .../src/app/store/messenger/room/effects.ts | 62 ++++++++++++++++++- 5 files changed, 142 insertions(+), 34 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 2e481ec1..21d1e8a6 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -576,9 +576,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { switch (menuType) { case 'ADD_MEMBER': { - console.log(this.roomInfo); - console.log(this.userInfoList); - const result = await this.dialogService.open< CreateChatDialogComponent, CreateChatDialogData, @@ -587,39 +584,36 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { width: '600px', data: { type: UserSelectDialogType.EditChatMember, - title: 'Edit Chat Member' - // , - // curRoomUser: this.userInfoList + title: 'Edit Chat Member', + curRoomUser: this.userInfoList.filter( + user => user.seq !== this.loginRes.userSeq + ) } }); if (!!result && !!result.choice && result.choice) { const userSeqs: number[] = []; - let roomSeq = ''; if ( !!result.selectedUserList && result.selectedUserList.length > 0 ) { - result.selectedUserList.map(user => userSeqs.push(user.seq)); + result.selectedUserList.map(user => { + userSeqs.push(user.seq); + }); } - if (!!result.selectedRoom) { - roomSeq = result.selectedRoom.roomSeq; - } + if (userSeqs.length > 0) { + // include me + userSeqs.push(this.loginRes.userSeq); - if (userSeqs.length > 0 || roomSeq.trim().length > 0) { - // this.store.dispatch( - // EventStore.forward({ - // senderSeq: this.loginRes.userSeq, - // req: { - // roomSeq: '-999', - // eventType: message.type, - // sentMessage: message.sentMessage - // }, - // trgtUserSeqs: userSeqs, - // trgtRoomSeq: roomSeq - // }) - // ); + this.store.dispatch( + RoomStore.inviteOrOpen({ + req: { + divCd: 'Invite', + userSeqs + } + }) + ); } } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html index eaa233e9..0b7338cc 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html @@ -73,7 +73,12 @@
-
검색결과 ({{ searchUserInfos.length }}명)
+
+ 검색결과 + ({{ searchUserInfos.length }}명) +
{{ userInfo.name }} - clear + clear + {{ selectedUserList.length }}명 diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts index dc4f3346..b39c00b5 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts @@ -57,12 +57,22 @@ export interface CreateChatDialogData { /** CASE :: EventForward */ ignoreRoom?: RoomInfo[]; /** CASE :: EditCharMember */ - curRoomUser?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[]; + curRoomUser?: ( + | UserInfo + | UserInfoSS + | UserInfoF + | UserInfoDN + | RoomUserInfo)[]; } export interface CreateChatDialogResult { choice: boolean; - selectedUserList?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[]; + selectedUserList?: ( + | UserInfo + | UserInfoSS + | UserInfoF + | UserInfoDN + | RoomUserInfo)[]; selectedRoom?: RoomInfo; groupName?: string; oldGroup?: GroupDetailData; @@ -117,7 +127,12 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { roomSubscription: Subscription; // 수집 데이터 - selectedUserList: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[] = []; + selectedUserList: ( + | UserInfo + | UserInfoSS + | UserInfoF + | UserInfoDN + | RoomUserInfo)[] = []; isShowSelectedUserList = true; selectedRoom: RoomInfo; @@ -208,6 +223,10 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { this.inputForm = this.formBuilder.group({ groupName: ['', [Validators.required]] }); + + if (this.data.type === UserSelectDialogType.EditChatMember) { + this.selectedUserList = this.data.curRoomUser; + } } ngOnDestroy(): void { @@ -239,6 +258,21 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { } } + getChipsRemoveYn(userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN) { + if ( + this.data.type === UserSelectDialogType.EditChatMember && + !!this.data.curRoomUser && + this.data.curRoomUser.length > 0 + ) { + return !( + this.data.curRoomUser.filter(user => user.seq === userInfo.seq).length > + 0 + ); + } else { + return true; + } + } + onSelectedTabChange(tabChangeEvent: MatTabChangeEvent): void { if (tabChangeEvent.index === 2) { this.selectedUserList = []; diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts index 5184c660..d0857791 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts @@ -15,7 +15,9 @@ import { ExitRequest, ExitResponse, Open3Request, - Open3Response + Open3Response, + InviteRequest, + InviteResponse } from '@ucap-webmessenger/protocol-room'; import { ReadNotification } from '@ucap-webmessenger/protocol-event'; @@ -115,6 +117,19 @@ export const openTimerFailure = createAction( props<{ error: any }>() ); +export const inviteOrOpen = createAction( + '[Messenger::Room] Invite or Open', + props<{ req: OpenRequest }>() +); +export const inviteSuccess = createAction( + '[Messenger::Room] Invite Success', + props() +); +export const inviteFailure = createAction( + '[Messenger::Room] Invite Failure', + props<{ error: any }>() +); + export const exit = createAction( '[Messenger::Room] Exit', props() diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts index ba8c3220..b45d6eb3 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts @@ -30,7 +30,9 @@ import { UpdateResponse, OpenResponse, ExitResponse, - Open3Response + Open3Response, + RoomType, + InviteResponse } from '@ucap-webmessenger/protocol-room'; import * as ChatStore from '@app/store/messenger/chat'; @@ -55,7 +57,10 @@ import { exitFailure, openTimer, openTimerSuccess, - openTimerFailure + openTimerFailure, + inviteOrOpen, + inviteSuccess, + inviteFailure } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -204,6 +209,59 @@ export class Effects { ) ); + inviteOrOpen$ = createEffect(() => + this.actions$.pipe( + ofType(inviteOrOpen), + withLatestFrom( + this.store.pipe( + select((state: any) => state.messenger.room.roomInfo as RoomInfo) + ) + ), + exhaustMap(([action, roomInfo]) => { + if (roomInfo.roomType === RoomType.Single) { + // Re Open + return this.roomProtocolService.open(action.req).pipe( + map((res: OpenResponse) => { + return openSuccess({ res }); + }), + catchError(error => of(openFailure({ error }))) + ); + } else if (roomInfo.roomType === RoomType.Multi) { + // Invite + return this.roomProtocolService + .invite({ + roomSeq: roomInfo.roomSeq, + inviteUserSeqs: action.req.userSeqs + }) + .pipe( + map((res: InviteResponse) => { + return inviteSuccess(res); + }), + catchError(error => of(inviteFailure({ error }))) + ); + } else { + return of(inviteFailure({ error: 'room type is error!!' })); + } + }) + ) + ); + inviteSuccess$ = createEffect(() => + this.actions$.pipe( + ofType(inviteSuccess), + map(action => { + return ChatStore.selectedRoom({ roomSeq: action.roomSeq }); + // const loginInfo = this.sessionStorageService.get( + // KEY_LOGIN_INFO + // ); + // return info({ + // roomSeq: action.roomSeq, + // isDetail: true, + // localeCode: loginInfo.localeCode + // }); + }) + ) + ); + exit$ = createEffect(() => this.actions$.pipe( ofType(exit),