openvidu-components: Refactored streams types enabled pipe

pull/809/head
Carlos Santos 2023-03-01 18:07:02 +01:00
parent d78774b218
commit 55db788f50
2 changed files with 12 additions and 15 deletions

View File

@ -160,13 +160,14 @@ export abstract class ParticipantAbstractModel {
/**
* @internal
* @returns The participant active connection types
*/
getConnectionTypesActive(): VideoType[] {
let connType = [];
if (this.isCameraActive()) connType.push(VideoType.CAMERA);
if (this.isScreenActive()) connType.push(VideoType.SCREEN);
getActiveConnectionTypes(): VideoType[] {
const activeTypes: VideoType[] = [];
if (this.isCameraActive()) activeTypes.push(VideoType.CAMERA);
if (this.isScreenActive()) activeTypes.push(VideoType.SCREEN);
return connType;
return activeTypes;
}
/**

View File

@ -27,15 +27,11 @@ export class StreamTypesEnabledPipe implements PipeTransform {
constructor(private translateService: TranslateService) {}
transform(participant: ParticipantAbstractModel): string {
let result = '';
let activeStreams = participant?.getConnectionTypesActive().toString();
const activeStreamsArr: string[] = activeStreams.split(',');
activeStreamsArr.forEach((type, index) => {
result += this.translateService.translate(`PANEL.PARTICIPANTS.${type}`)
if(activeStreamsArr.length > 0 && index < activeStreamsArr.length - 1){
result += ', ';
}
});
return `(${result})`;
const activeStreams = participant?.getActiveConnectionTypes() ?? [];
const streamNames = activeStreams.map(streamType => this.translateService.translate(`PANEL.PARTICIPANTS.${streamType}`));
const streamsString = streamNames.join(', ');
return `(${streamsString})`;
}
}