leejinho 2dcd0036d0 ## 방정보.참여자 정보 수정.
1. isJoinRoom 값에 따른 화면별 처리.

## 강퇴기능 씽크 제반 작업.
1.  모바일 씽크작업.
2. 강퇴 메시지 처리.

## 사용자 초대 ::
1. 모바일과 씽크.
2. 초대시 방정보 갱신되지 않는 문제 수정.
2019-12-09 16:52:43 +09:00

113 lines
3.1 KiB
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import {
Info,
EventType,
EventJson,
JoinEventJson,
RenameRoomEventJson,
NotificationForTimerRoomEventJson,
GuideForRoomTimerChangedEventJson
} from '@ucap-webmessenger/protocol-event';
@Component({
selector: 'ucap-chat-message-box-information',
templateUrl: './information.component.html',
styleUrls: ['./information.component.scss']
})
export class InformationComponent implements OnInit {
@Input()
message: Info<EventJson>;
@Input()
senderName?: string;
contents: string;
constructor(private logger: NGXLogger) {}
ngOnInit() {
switch (this.message.type) {
case EventType.Join:
{
const m = this.message as Info<JoinEventJson>;
const owner = m.sentMessageJson.owner + '님';
const inviter: string[] = [];
m.sentMessageJson.inviter.forEach((userName, idx) => {
inviter.push(userName + '님');
});
this.contents = `${owner}${inviter.join(',')}을 초대했습니다.`;
}
break;
case EventType.Exit:
{
const m = this.message as Info<JoinEventJson>;
this.contents = `${m.sentMessage}님이 퇴장하셨습니다.`;
}
break;
case EventType.ForcedExit:
{
const m = this.message as Info<JoinEventJson>;
this.contents = `${m.exitForcingRequestUserName} 님이 ${m.sentMessage} 님을 퇴장 시키셨습니다.`;
}
break;
case EventType.RenameRoom:
{
const m = this.message as Info<RenameRoomEventJson>;
this.contents = `${m.sentMessageJson.requester}님이 대화방명을 '${m.sentMessageJson.roomName}'으로 변경하셨습니다.`;
}
break;
case EventType.NotificationForTimerRoom:
{
const m = this.message as Info<NotificationForTimerRoomEventJson>;
/**
* 타이머대화방 알림으로서 채팅 이벤트에서 처리하지 않고, 대화방 글로벌에서 처리.
*/
this.contents = m.sentMessage;
}
break;
case EventType.GuideForRoomTimerChanged:
{
const m = this.message as Info<GuideForRoomTimerChangedEventJson>;
this.contents = `${
this.senderName
}님이 타이머를 설정하였습니다.(${this.getCalcTimer(
m.sentMessageJson.time * 1000
)})`;
}
break;
}
}
getCalcTimer(millisec: number) {
switch (millisec) {
case 5000:
return '5 초';
case 10000:
return '10 초';
case 30000:
return '30 초';
case 60000:
return '1 분';
case 300000:
return '5 분';
case 600000:
return '10 분';
case 1800000:
return '30 분';
case 3600000:
return '1 시간';
case 21600000:
return '6 시간';
case 43200000:
return '12 시간';
case 86400000:
return '24 시간';
default:
return '0 초';
}
}
}