수정 :: 대화 > 리스트의 finalEventMessage 처리

This commit is contained in:
leejh 2019-10-16 09:01:03 +09:00
parent 7ec9d2356b
commit a679f4b2b9
2 changed files with 66 additions and 3 deletions

View File

@ -1,5 +1,6 @@
<div> <div>
<div class="room-name">{{ getRoomName(roomInfo) }}</div> <div class="room-name">{{ getRoomName(roomInfo) }}</div>
<div>{{ roomInfo.finalEventDate }}</div> <div>{{ roomInfo.finalEventDate }}</div>
<div>{{ roomInfo.finalEventMessage }}</div> <div>{{ finalEventMessage }}</div>
<div *ngIf="roomInfo.noReadCnt > 0">noReadCnt : {{ roomInfo.noReadCnt }}</div>
</div> </div>

View File

@ -2,10 +2,18 @@ import { Component, OnInit, Input } from '@angular/core';
import { import {
RoomInfo, RoomInfo,
UserInfoShort, UserInfoShort,
UserInfo as RoomUserInfo UserInfo as RoomUserInfo,
RoomType
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { EventType } from '@ucap-webmessenger/protocol-event';
import {
FileInfo,
StickerInfo,
MassTextInfo
} from '@ucap-webmessenger/ui-chat';
import { FileType } from '@ucap-webmessenger/protocol-file';
@Component({ @Component({
selector: 'ucap-room-list-item', selector: 'ucap-room-list-item',
@ -20,10 +28,60 @@ export class ListItemComponent implements OnInit {
@Input() @Input()
sessionVerinfo: VersionInfo2Response; sessionVerinfo: VersionInfo2Response;
finalEventMessage: string;
constructor(private logger: NGXLogger) {} constructor(private logger: NGXLogger) {}
ngOnInit() { ngOnInit() {
// this.logger.debug(this.roomInfo); if (this.roomInfo.isTimeRoom) {
this.finalEventMessage = '비밀 대화방입니다.';
} else {
try {
switch (this.roomInfo.finalEventType) {
case EventType.File:
{
let msg = 'Attach File';
const contentJson: FileInfo = JSON.parse(
this.roomInfo.finalEventMessage
);
if (contentJson.FileType === FileType.File) {
msg = '첨부파일';
} else if (contentJson.FileType === FileType.Image) {
msg = '이미지';
} else if (contentJson.FileType === FileType.Video) {
msg = '동영상';
}
this.finalEventMessage = msg;
}
break;
case EventType.Sticker:
{
let msg = '스티커';
const contentJson: StickerInfo = JSON.parse(
this.roomInfo.finalEventMessage
);
if (contentJson.chat) {
msg += ' ' + contentJson.chat;
}
this.finalEventMessage = msg;
}
break;
case EventType.MassText:
{
const contentJson: MassTextInfo = JSON.parse(
this.roomInfo.finalEventMessage
);
this.finalEventMessage = contentJson.Content;
}
break;
default:
this.finalEventMessage = this.roomInfo.finalEventMessage;
}
} catch (e) {
this.logger.error(e);
this.finalEventMessage = this.roomInfo.finalEventMessage;
}
}
} }
getRoomName(roomInfo: RoomInfo): string { getRoomName(roomInfo: RoomInfo): string {
@ -31,6 +89,10 @@ export class ListItemComponent implements OnInit {
return roomInfo.roomName; return roomInfo.roomName;
} }
if (roomInfo.roomType === RoomType.Mytalk) {
return 'MyTalk';
}
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) { if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
let roomName = ''; let roomName = '';
this.roomUserInfo.forEach((roomUserInfo, index) => { this.roomUserInfo.forEach((roomUserInfo, index) => {