ov-components: refactor participant name retrieval logic in VideoconferenceComponent

master
Carlos Santos 2025-05-20 12:40:22 +02:00
parent 4ad8c52c38
commit 5df42d5344
1 changed files with 22 additions and 24 deletions

View File

@ -556,31 +556,29 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
// We have a name, proceed immediately // We have a name, proceed immediately
this._onReadyToJoin(); this._onReadyToJoin();
} else { } else {
// Try to get it from storage first // No name yet - set up a one-time subscription to wait for it
const storedName = this.storageSrv.getParticipantName(); const waitForNameSub = this.libService.participantName$
if (storedName) { .pipe(
this.latestParticipantName = storedName; filter((name) => !!name),
this._onReadyToJoin(); take(1)
} else { )
// No name yet - set up a one-time subscription to wait for it .subscribe(() => {
const waitForNameSub = this.libService.participantName$ // Now we have the name in latestParticipantName
.pipe( this._onReadyToJoin();
filter((name) => !!name), });
take(1) // Add safety timeout in case name never arrives
) setTimeout(() => {
.subscribe(() => { if (!this.latestParticipantName) {
// Now we have the name in latestParticipantName this.log.w('No participant name received after timeout, proceeding anyway');
this._onReadyToJoin(); waitForNameSub.unsubscribe();
}); const storedName = this.storageSrv.getParticipantName();
// Add safety timeout in case name never arrives if (storedName) {
setTimeout(() => { this.latestParticipantName = storedName;
if (!this.latestParticipantName) { this.libService.setParticipantName(storedName);
this.log.w('No participant name received after timeout, proceeding anyway');
waitForNameSub.unsubscribe();
this._onReadyToJoin();
} }
}, 1000); this._onReadyToJoin();
} }
}, 1000);
} }
} }
// this.cd.markForCheck(); // this.cd.markForCheck();