From 5df42d53441b4ccb836c9e2013993a52452cc858 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 20 May 2025 12:40:22 +0200 Subject: [PATCH] ov-components: refactor participant name retrieval logic in VideoconferenceComponent --- .../videoconference.component.ts | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/videoconference/videoconference.component.ts b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/videoconference/videoconference.component.ts index 96f50142..50bfa747 100644 --- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/videoconference/videoconference.component.ts +++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/videoconference/videoconference.component.ts @@ -556,31 +556,29 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit { // We have a name, proceed immediately this._onReadyToJoin(); } else { - // Try to get it from storage first - const storedName = this.storageSrv.getParticipantName(); - if (storedName) { - this.latestParticipantName = storedName; - this._onReadyToJoin(); - } else { - // No name yet - set up a one-time subscription to wait for it - const waitForNameSub = this.libService.participantName$ - .pipe( - filter((name) => !!name), - take(1) - ) - .subscribe(() => { - // Now we have the name in latestParticipantName - this._onReadyToJoin(); - }); - // Add safety timeout in case name never arrives - setTimeout(() => { - if (!this.latestParticipantName) { - this.log.w('No participant name received after timeout, proceeding anyway'); - waitForNameSub.unsubscribe(); - this._onReadyToJoin(); + // No name yet - set up a one-time subscription to wait for it + const waitForNameSub = this.libService.participantName$ + .pipe( + filter((name) => !!name), + take(1) + ) + .subscribe(() => { + // Now we have the name in latestParticipantName + this._onReadyToJoin(); + }); + // Add safety timeout in case name never arrives + setTimeout(() => { + if (!this.latestParticipantName) { + this.log.w('No participant name received after timeout, proceeding anyway'); + waitForNameSub.unsubscribe(); + const storedName = this.storageSrv.getParticipantName(); + if (storedName) { + this.latestParticipantName = storedName; + this.libService.setParticipantName(storedName); } - }, 1000); - } + this._onReadyToJoin(); + } + }, 1000); } } // this.cd.markForCheck();