ov-components: introduce isVideoconferenceHost utility function and update clear logic in directives

pull/900/head
CSantosM 2026-05-11 13:09:00 +02:00
parent dae34746dc
commit ac546ed130
5 changed files with 88 additions and 24 deletions

View File

@ -1,6 +1,10 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/**
* The **recordingActivity** directive allows show/hide the recording activity in {@link ActivitiesPanelComponent}.
*
@ -41,7 +45,9 @@ export class ActivitiesPanelRecordingActivityDirective implements AfterViewInit,
this.update(this.recordingActivityValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
clear() {
this.recordingActivityValue = true;
@ -93,7 +99,9 @@ export class ActivitiesPanelBroadcastingActivityDirective implements AfterViewIn
this.update(this.broadcastingActivityValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
clear() {
this.broadcastingActivityValue = true;

View File

@ -4,6 +4,10 @@ import { AfterViewInit, Directive, ElementRef, HostListener, Input, OnDestroy, O
import { ParticipantModel } from '../../models/participant.model';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/**
* Load default OpenVidu logo if custom one is not exist
* @internal
@ -70,7 +74,9 @@ export class LayoutRemoteParticipantsDirective {
) {}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
ngAfterViewInit() {
@ -117,7 +123,9 @@ export class ToolbarBrandingLogoDirective implements AfterViewInit, OnDestroy {
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this._brandingLogo = '';
@ -153,7 +161,9 @@ export class PrejoinDisplayParticipantName implements OnDestroy {
) {}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
@ -333,7 +343,7 @@ export class ToolbarViewRecordingsButtonDirective implements AfterViewInit, OnDe
}
private clear() {
this.viewRecordingsValue = false;
this.update(true);
this.update(this.viewRecordingsValue);
}
private update(value: boolean) {
@ -469,7 +479,7 @@ export class RecordingActivityShowRecordingsListDirective implements AfterViewIn
}
private clear() {
this._value = true;
this._value = false;
this.update(this._value);
}

View File

@ -1,6 +1,10 @@
import { Directive, AfterViewInit, OnDestroy, Input, ElementRef } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/**
* The **muteButton** directive allows show/hide the muted button in participant panel item component.
*
@ -41,7 +45,9 @@ export class ParticipantPanelItemMuteButtonDirective implements AfterViewInit, O
this.update(this.muteValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
clear() {
this.muteValue = true;

View File

@ -1,6 +1,10 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/**
* The **displayParticipantName** directive allows show/hide the participants name in stream component.
*
@ -38,7 +42,9 @@ export class StreamDisplayParticipantNameDirective implements AfterViewInit, OnD
) {}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
ngAfterViewInit() {
@ -94,7 +100,9 @@ export class StreamDisplayAudioDetectionDirective implements AfterViewInit, OnDe
this.update(this.displayAudioDetectionValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
update(value: boolean) {
@ -146,7 +154,9 @@ export class StreamVideoControlsDirective implements AfterViewInit, OnDestroy {
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
update(value: boolean) {

View File

@ -2,6 +2,10 @@ import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/**
* The **cameraButton** directive allows show/hide the camera toolbar button.
*
@ -53,7 +57,9 @@ export class ToolbarCameraButtonDirective implements AfterViewInit, OnDestroy {
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
@ -117,7 +123,9 @@ export class ToolbarMicrophoneButtonDirective implements AfterViewInit, OnDestro
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
@ -181,7 +189,9 @@ export class ToolbarScreenshareButtonDirective implements AfterViewInit, OnDestr
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
@ -243,7 +253,9 @@ export class ToolbarRecordingButtonDirective implements AfterViewInit, OnDestroy
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.recordingValue = true;
@ -305,7 +317,9 @@ export class ToolbarBroadcastingButtonDirective implements AfterViewInit, OnDest
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.broadcastingValue = true;
@ -366,7 +380,9 @@ export class ToolbarFullscreenButtonDirective implements AfterViewInit, OnDestro
this.update(this.fullscreenValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.fullscreenValue = true;
@ -427,7 +443,9 @@ export class ToolbarBackgroundEffectsButtonDirective implements AfterViewInit, O
this.update(this.backgroundEffectsValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.backgroundEffectsValue = true;
@ -547,7 +565,9 @@ export class ToolbarSettingsButtonDirective implements AfterViewInit, OnDestroy
this.update(this.settingsValue);
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.settingsValue = true;
@ -609,7 +629,9 @@ export class ToolbarLeaveButtonDirective implements AfterViewInit, OnDestroy {
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.leaveValue = true;
@ -672,7 +694,9 @@ export class ToolbarParticipantsPanelButtonDirective implements AfterViewInit, O
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.participantsPanelValue = true;
@ -733,7 +757,9 @@ export class ToolbarChatPanelButtonDirective implements AfterViewInit, OnDestroy
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.toolbarChatPanelValue = true;
@ -794,7 +820,9 @@ export class ToolbarActivitiesPanelButtonDirective implements AfterViewInit, OnD
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.toolbarActivitiesPanelValue = true;
@ -856,7 +884,9 @@ export class ToolbarDisplayRoomNameDirective implements AfterViewInit, OnDestroy
}
ngOnDestroy(): void {
this.clear();
if (isVideoconferenceHost(this.elementRef)) {
this.clear();
}
}
private clear() {
this.displayRoomValue = true;