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 * @internal
* @returns The participant active connection types
*/ */
getConnectionTypesActive(): VideoType[] { getActiveConnectionTypes(): VideoType[] {
let connType = []; const activeTypes: VideoType[] = [];
if (this.isCameraActive()) connType.push(VideoType.CAMERA); if (this.isCameraActive()) activeTypes.push(VideoType.CAMERA);
if (this.isScreenActive()) connType.push(VideoType.SCREEN); 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) {} constructor(private translateService: TranslateService) {}
transform(participant: ParticipantAbstractModel): string { transform(participant: ParticipantAbstractModel): string {
let result = '';
let activeStreams = participant?.getConnectionTypesActive().toString(); const activeStreams = participant?.getActiveConnectionTypes() ?? [];
const activeStreamsArr: string[] = activeStreams.split(','); const streamNames = activeStreams.map(streamType => this.translateService.translate(`PANEL.PARTICIPANTS.${streamType}`));
activeStreamsArr.forEach((type, index) => { const streamsString = streamNames.join(', ');
result += this.translateService.translate(`PANEL.PARTICIPANTS.${type}`)
if(activeStreamsArr.length > 0 && index < activeStreamsArr.length - 1){ return `(${streamsString})`;
result += ', ';
}
});
return `(${result})`;
} }
} }