2019-10-10 15:50:50 +09:00
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
|
|
|
import {
|
|
|
|
RoomInfo,
|
|
|
|
UserInfoShort,
|
2019-10-16 09:01:03 +09:00
|
|
|
UserInfo as RoomUserInfo,
|
|
|
|
RoomType
|
2019-10-10 15:50:50 +09:00
|
|
|
} from '@ucap-webmessenger/protocol-room';
|
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-15 16:59:05 +09:00
|
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
2019-10-16 09:01:03 +09:00
|
|
|
import { EventType } from '@ucap-webmessenger/protocol-event';
|
|
|
|
import {
|
|
|
|
FileInfo,
|
|
|
|
StickerInfo,
|
|
|
|
MassTextInfo
|
|
|
|
} from '@ucap-webmessenger/ui-chat';
|
|
|
|
import { FileType } from '@ucap-webmessenger/protocol-file';
|
2019-10-10 15:50:50 +09:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ucap-room-list-item',
|
|
|
|
templateUrl: './list-item.component.html',
|
|
|
|
styleUrls: ['./list-item.component.scss']
|
|
|
|
})
|
|
|
|
export class ListItemComponent implements OnInit {
|
|
|
|
@Input()
|
|
|
|
roomInfo: RoomInfo;
|
|
|
|
@Input()
|
|
|
|
roomUserInfo: RoomUserInfo[] | UserInfoShort[];
|
2019-10-15 16:59:05 +09:00
|
|
|
@Input()
|
|
|
|
sessionVerinfo: VersionInfo2Response;
|
2019-10-10 15:50:50 +09:00
|
|
|
|
2019-10-16 09:01:03 +09:00
|
|
|
finalEventMessage: string;
|
|
|
|
|
2019-10-10 15:50:50 +09:00
|
|
|
constructor(private logger: NGXLogger) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-16 09:01:03 +09:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
getRoomName(roomInfo: RoomInfo): string {
|
|
|
|
if (!!roomInfo.roomName && '' !== roomInfo.roomName.trim()) {
|
|
|
|
return roomInfo.roomName;
|
|
|
|
}
|
|
|
|
|
2019-10-16 09:01:03 +09:00
|
|
|
if (roomInfo.roomType === RoomType.Mytalk) {
|
|
|
|
return 'MyTalk';
|
|
|
|
}
|
|
|
|
|
2019-10-10 15:50:50 +09:00
|
|
|
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
|
|
|
|
let roomName = '';
|
|
|
|
this.roomUserInfo.forEach((roomUserInfo, index) => {
|
|
|
|
if (0 === index) {
|
|
|
|
roomName = roomName.concat('', roomUserInfo.name);
|
|
|
|
} else {
|
|
|
|
roomName = roomName.concat(',', roomUserInfo.name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return roomName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|