From 649775137592a29afe80d0bd709d87c4df97b290 Mon Sep 17 00:00:00 2001
From: Carlos Santos <4a.santos@gmail.com>
Date: Fri, 4 Jul 2025 12:45:16 +0200
Subject: [PATCH] ov-component: add showDisconnectionDialog directive and
update service for disconnection dialog management
---
.../components/session/session.component.ts | 2 +-
.../api/videoconference.directive.ts | 54 +++++++++++++++++++
.../config/directive-config.service.ts | 11 ++++
3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/session/session.component.ts b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/session/session.component.ts
index ad0c58cf..794be160 100644
--- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/session/session.component.ts
+++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/session/session.component.ts
@@ -532,7 +532,7 @@ export class SessionComponent implements OnInit, OnDestroy {
this.log.d('Participant disconnected', participantLeftEvent);
this.onParticipantLeft.emit(participantLeftEvent);
this.onRoomDisconnected.emit();
- if (descriptionErrorKey) {
+ if (this.libService.getShowDisconnectionDialog() && descriptionErrorKey) {
this.actionService.openDialog(
this.translateService.translate(messageErrorKey),
this.translateService.translate(descriptionErrorKey)
diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/directives/api/videoconference.directive.ts b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/directives/api/videoconference.directive.ts
index 5833d0a1..afb60476 100644
--- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/directives/api/videoconference.directive.ts
+++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/directives/api/videoconference.directive.ts
@@ -736,6 +736,60 @@ export class AudioEnabledDirective implements OnDestroy {
}
}
+/**
+ * The **showDisconnectionDialog** directive allows to show/hide the disconnection dialog when the local participant is disconnected from the room.
+ *
+ * It is only available for {@link VideoconferenceComponent}.
+ *
+ * Default: `true`
+ *
+ * @example
+ *
+ */
+@Directive({
+ selector: 'ov-videoconference[showDisconnectionDialog]',
+ standalone: false
+})
+export class ShowDisconnectionDialogDirective implements OnDestroy {
+ /**
+ * @ignore
+ */
+ @Input() set showDisconnectionDialog(value: boolean) {
+ this.update(value);
+ }
+
+ /**
+ * @ignore
+ */
+ constructor(
+ public elementRef: ElementRef,
+ private libService: OpenViduComponentsConfigService
+ ) {}
+
+ /**
+ * @ignore
+ */
+ ngOnDestroy(): void {
+ this.clear();
+ }
+
+ /**
+ * @ignore
+ */
+ clear() {
+ this.update(true);
+ }
+
+ /**
+ * @ignore
+ */
+ update(value: boolean) {
+ if (this.libService.getShowDisconnectionDialog() !== value) {
+ this.libService.setShowDisconnectionDialog(value);
+ }
+ }
+}
+
/**
* The **recordingStreamBaseUrl** directive sets the base URL for retrieving recording streams.
* The complete request URL is dynamically constructed by concatenating the supplied URL, the
diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/services/config/directive-config.service.ts b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/services/config/directive-config.service.ts
index c686f548..c028169b 100644
--- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/services/config/directive-config.service.ts
+++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/services/config/directive-config.service.ts
@@ -33,6 +33,9 @@ export class OpenViduComponentsConfigService {
private audioEnabled = >new BehaviorSubject(true);
audioEnabled$: Observable;
+ private showDisconnectionDialog = >new BehaviorSubject(true);
+ showDisconnectionDialog$: Observable;
+
private recordingStreamBaseUrl = >new BehaviorSubject('call/api/recordings');
recordingStreamBaseUrl$: Observable;
@@ -218,6 +221,14 @@ export class OpenViduComponentsConfigService {
return this.audioEnabled.getValue();
}
+ getShowDisconnectionDialog(): boolean {
+ return this.showDisconnectionDialog.getValue();
+ }
+
+ setShowDisconnectionDialog(showDisconnectionDialog: boolean) {
+ this.showDisconnectionDialog.next(showDisconnectionDialog);
+ }
+
setRecordingStreamBaseUrl(recordingStreamBaseUrl: string) {
this.recordingStreamBaseUrl.next(recordingStreamBaseUrl);
}