기능추기 :: 대화 상대 추가

This commit is contained in:
leejh 2019-11-04 11:36:58 +09:00
parent 610ca140a6
commit c7a7f6ca23
5 changed files with 142 additions and 34 deletions

View File

@ -576,9 +576,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
switch (menuType) { switch (menuType) {
case 'ADD_MEMBER': case 'ADD_MEMBER':
{ {
console.log(this.roomInfo);
console.log(this.userInfoList);
const result = await this.dialogService.open< const result = await this.dialogService.open<
CreateChatDialogComponent, CreateChatDialogComponent,
CreateChatDialogData, CreateChatDialogData,
@ -587,39 +584,36 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
width: '600px', width: '600px',
data: { data: {
type: UserSelectDialogType.EditChatMember, type: UserSelectDialogType.EditChatMember,
title: 'Edit Chat Member' title: 'Edit Chat Member',
// , curRoomUser: this.userInfoList.filter(
// curRoomUser: this.userInfoList user => user.seq !== this.loginRes.userSeq
)
} }
}); });
if (!!result && !!result.choice && result.choice) { if (!!result && !!result.choice && result.choice) {
const userSeqs: number[] = []; const userSeqs: number[] = [];
let roomSeq = '';
if ( if (
!!result.selectedUserList && !!result.selectedUserList &&
result.selectedUserList.length > 0 result.selectedUserList.length > 0
) { ) {
result.selectedUserList.map(user => userSeqs.push(user.seq)); result.selectedUserList.map(user => {
userSeqs.push(user.seq);
});
} }
if (!!result.selectedRoom) { if (userSeqs.length > 0) {
roomSeq = result.selectedRoom.roomSeq; // include me
} userSeqs.push(this.loginRes.userSeq);
if (userSeqs.length > 0 || roomSeq.trim().length > 0) { this.store.dispatch(
// this.store.dispatch( RoomStore.inviteOrOpen({
// EventStore.forward({ req: {
// senderSeq: this.loginRes.userSeq, divCd: 'Invite',
// req: { userSeqs
// roomSeq: '-999', }
// eventType: message.type, })
// sentMessage: message.sentMessage );
// },
// trgtUserSeqs: userSeqs,
// trgtRoomSeq: roomSeq
// })
// );
} }
} }
} }

View File

@ -73,7 +73,12 @@
<div *ngIf="searchProcessing"> <div *ngIf="searchProcessing">
<mat-progress-bar mode="indeterminate"></mat-progress-bar> <mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div> </div>
<div class="result-num">검색결과 <span class="text-accent-color">({{ searchUserInfos.length }}명)</span></div> <div class="result-num">
검색결과
<span class="text-accent-color"
>({{ searchUserInfos.length }}명)</span
>
</div>
<ucap-profile-user-list-item <ucap-profile-user-list-item
*ngFor="let userInfo of searchUserInfos" *ngFor="let userInfo of searchUserInfos"
[userInfo]="userInfo" [userInfo]="userInfo"
@ -141,15 +146,17 @@
<mat-chip-list aria-label="User selection"> <mat-chip-list aria-label="User selection">
<mat-chip <mat-chip
*ngFor="let userInfo of selectedUserList" *ngFor="let userInfo of selectedUserList"
color="primary" [selected]="getChipsRemoveYn(userInfo)"
selected
(removed)="onClickDeleteUser(userInfo)" (removed)="onClickDeleteUser(userInfo)"
> >
{{ userInfo.name }} {{ userInfo.name }}
<mat-icon matChipRemove>clear</mat-icon> <mat-icon matChipRemove *ngIf="getChipsRemoveYn(userInfo)"
>clear</mat-icon
>
</mat-chip> </mat-chip>
</mat-chip-list> </mat-chip-list>
</div> </div>
<span>{{ selectedUserList.length }}명</span>
</div> </div>
</mat-card-content> </mat-card-content>
<mat-card-actions class="button-farm flex-row"> <mat-card-actions class="button-farm flex-row">

View File

@ -57,12 +57,22 @@ export interface CreateChatDialogData {
/** CASE :: EventForward */ /** CASE :: EventForward */
ignoreRoom?: RoomInfo[]; ignoreRoom?: RoomInfo[];
/** CASE :: EditCharMember */ /** CASE :: EditCharMember */
curRoomUser?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[]; curRoomUser?: (
| UserInfo
| UserInfoSS
| UserInfoF
| UserInfoDN
| RoomUserInfo)[];
} }
export interface CreateChatDialogResult { export interface CreateChatDialogResult {
choice: boolean; choice: boolean;
selectedUserList?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[]; selectedUserList?: (
| UserInfo
| UserInfoSS
| UserInfoF
| UserInfoDN
| RoomUserInfo)[];
selectedRoom?: RoomInfo; selectedRoom?: RoomInfo;
groupName?: string; groupName?: string;
oldGroup?: GroupDetailData; oldGroup?: GroupDetailData;
@ -117,7 +127,12 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
roomSubscription: Subscription; roomSubscription: Subscription;
// 수집 데이터 // 수집 데이터
selectedUserList: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[] = []; selectedUserList: (
| UserInfo
| UserInfoSS
| UserInfoF
| UserInfoDN
| RoomUserInfo)[] = [];
isShowSelectedUserList = true; isShowSelectedUserList = true;
selectedRoom: RoomInfo; selectedRoom: RoomInfo;
@ -208,6 +223,10 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
this.inputForm = this.formBuilder.group({ this.inputForm = this.formBuilder.group({
groupName: ['', [Validators.required]] groupName: ['', [Validators.required]]
}); });
if (this.data.type === UserSelectDialogType.EditChatMember) {
this.selectedUserList = this.data.curRoomUser;
}
} }
ngOnDestroy(): void { 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 { onSelectedTabChange(tabChangeEvent: MatTabChangeEvent): void {
if (tabChangeEvent.index === 2) { if (tabChangeEvent.index === 2) {
this.selectedUserList = []; this.selectedUserList = [];

View File

@ -15,7 +15,9 @@ import {
ExitRequest, ExitRequest,
ExitResponse, ExitResponse,
Open3Request, Open3Request,
Open3Response Open3Response,
InviteRequest,
InviteResponse
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import { ReadNotification } from '@ucap-webmessenger/protocol-event'; import { ReadNotification } from '@ucap-webmessenger/protocol-event';
@ -115,6 +117,19 @@ export const openTimerFailure = createAction(
props<{ error: any }>() props<{ error: any }>()
); );
export const inviteOrOpen = createAction(
'[Messenger::Room] Invite or Open',
props<{ req: OpenRequest }>()
);
export const inviteSuccess = createAction(
'[Messenger::Room] Invite Success',
props<InviteResponse>()
);
export const inviteFailure = createAction(
'[Messenger::Room] Invite Failure',
props<{ error: any }>()
);
export const exit = createAction( export const exit = createAction(
'[Messenger::Room] Exit', '[Messenger::Room] Exit',
props<ExitRequest>() props<ExitRequest>()

View File

@ -30,7 +30,9 @@ import {
UpdateResponse, UpdateResponse,
OpenResponse, OpenResponse,
ExitResponse, ExitResponse,
Open3Response Open3Response,
RoomType,
InviteResponse
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import * as ChatStore from '@app/store/messenger/chat'; import * as ChatStore from '@app/store/messenger/chat';
@ -55,7 +57,10 @@ import {
exitFailure, exitFailure,
openTimer, openTimer,
openTimerSuccess, openTimerSuccess,
openTimerFailure openTimerFailure,
inviteOrOpen,
inviteSuccess,
inviteFailure
} from './actions'; } from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; 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<LoginInfo>(
// KEY_LOGIN_INFO
// );
// return info({
// roomSeq: action.roomSeq,
// isDetail: true,
// localeCode: loginInfo.localeCode
// });
})
)
);
exit$ = createEffect(() => exit$ = createEffect(() =>
this.actions$.pipe( this.actions$.pipe(
ofType(exit), ofType(exit),