47 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Component, OnInit, Input } from '@angular/core';
import {
RoomInfo,
UserInfoShort,
UserInfo as RoomUserInfo
} from '@ucap-webmessenger/protocol-room';
import { NGXLogger } from 'ngx-logger';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
@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[];
@Input()
sessionVerinfo: VersionInfo2Response;
constructor(private logger: NGXLogger) {}
ngOnInit() {
// this.logger.debug(this.roomInfo);
}
getRoomName(roomInfo: RoomInfo): string {
if (!!roomInfo.roomName && '' !== roomInfo.roomName.trim()) {
return roomInfo.roomName;
}
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;
}
}
}