기능추가 :: 대화방 > 대화방명 데이터 매핑.

This commit is contained in:
leejh 2019-10-22 09:30:23 +09:00
parent 8fdfb528f5
commit d2a2115f33
2 changed files with 42 additions and 16 deletions

View File

@ -2,7 +2,7 @@
<div class="container" fxFlex fxLayout="column"> <div class="container" fxFlex fxLayout="column">
<!-- CHAT TOOLBAR --> <!-- CHAT TOOLBAR -->
<mat-toolbar class="chat-toolbar"> <mat-toolbar class="chat-toolbar">
<div fxFlex fxLayout="row" class="chat-header" > <div fxFlex fxLayout="row" class="chat-header">
<div fxLayout="row" fxLayoutAlign="start center" class="profile-img"> <div fxLayout="row" fxLayoutAlign="start center" class="profile-img">
<!-- RESPONSIVE CHATS BUTTON--> <!-- RESPONSIVE CHATS BUTTON-->
<button <button
@ -16,7 +16,7 @@
<!-- / RESPONSIVE CHATS BUTTON--> <!-- / RESPONSIVE CHATS BUTTON-->
</div> </div>
<div class="room-name"> <div class="room-name">
대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명대화방명 {{ getRoomName() }}
</div> </div>
<div class="room-option"> <div class="room-option">
<button <button
@ -72,7 +72,7 @@
<!-- CHAT MESSAGES --> <!-- CHAT MESSAGES -->
<ucap-chat-messages <ucap-chat-messages
[messages]="eventList$ | async" [messages]="eventList$ | async"
[userInfos]="userInfoList$ | async" [userInfos]="userInfoList"
[loginRes]="loginRes" [loginRes]="loginRes"
[sessionVerInfo]="sessionVerInfo" [sessionVerInfo]="sessionVerInfo"
(massDetail)="onMassDetail($event)" (massDetail)="onMassDetail($event)"

View File

@ -29,13 +29,8 @@ import * as ChatStore from '@app/store/messenger/chat';
import * as RoomStore from '@app/store/messenger/room'; import * as RoomStore from '@app/store/messenger/room';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types';
LoginInfo, import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
KEY_LOGIN_INFO,
EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO
} from '@app/types';
import { RoomInfo, UserInfo } from '@ucap-webmessenger/protocol-room';
import { tap, take } from 'rxjs/operators'; import { tap, take } from 'rxjs/operators';
import { FileInfo } from '@ucap-webmessenger/ui-chat'; import { FileInfo } from '@ucap-webmessenger/ui-chat';
import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { KEY_VER_INFO } from '@app/types/ver-info.type';
@ -80,7 +75,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
eventList$: Observable<Info[]>; eventList$: Observable<Info[]>;
roomInfo: RoomInfo; roomInfo: RoomInfo;
roomInfoSubscription: Subscription; roomInfoSubscription: Subscription;
userInfoList$: Observable<UserInfo[]>; userInfoList: UserInfo[];
userInfoListSubscription: Subscription;
eventListProcessing$: Observable<boolean>; eventListProcessing$: Observable<boolean>;
sessionVerInfo: VersionInfo2Response; sessionVerInfo: VersionInfo2Response;
@ -110,8 +106,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
} }
ngOnInit() { ngOnInit() {
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
this.loginResSubscription = this.store this.loginResSubscription = this.store
.pipe( .pipe(
select(AppStore.AccountSelector.AuthenticationSelector.loginRes), select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
@ -130,9 +124,14 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
) )
.subscribe(); .subscribe();
this.userInfoList$ = this.store.pipe( this.userInfoListSubscription = this.store
select(AppStore.MessengerSelector.RoomSelector.userInfoList) .pipe(
); select(AppStore.MessengerSelector.RoomSelector.userInfoList),
tap(userInfoList => {
this.userInfoList = userInfoList;
})
)
.subscribe();
this.eventListProcessing$ = this.store.pipe( this.eventListProcessing$ = this.store.pipe(
select(AppStore.MessengerSelector.EventSelector.infoListProcessing) select(AppStore.MessengerSelector.EventSelector.infoListProcessing)
@ -152,12 +151,39 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
if (!!this.roomInfoSubscription) { if (!!this.roomInfoSubscription) {
this.roomInfoSubscription.unsubscribe(); this.roomInfoSubscription.unsubscribe();
} }
if (!!this.userInfoListSubscription) {
this.userInfoListSubscription.unsubscribe();
}
} }
ngAfterViewChecked(): void { ngAfterViewChecked(): void {
this.scrollToBottomForMessageBoxContainer(); this.scrollToBottomForMessageBoxContainer();
} }
getRoomName() {
if (!this.roomInfo || !this.userInfoList) {
return '대화방명을 가져오고 있습니다..';
}
if (!!this.roomInfo.roomName && '' !== this.roomInfo.roomName.trim()) {
return this.roomInfo.roomName;
} else if (this.roomInfo.roomType === RoomType.Mytalk) {
return 'MyTalk';
} else {
return this.userInfoList
.filter(user => {
if (this.roomInfo.roomType === RoomType.Single) {
return user.seq !== this.loginRes.userSeq;
} else {
return true;
}
})
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
.map(user => user.name)
.join(',');
}
}
selectContact() {} selectContact() {}
onSendMessage(message: string) { onSendMessage(message: string) {