ov-components: Fixed bug showing prejoin

- Rename joinSession method to join and update related calls for consistency
refactor
- Change isPrejoin method to showPrejoin in directive config service
master
Carlos Santos 2025-07-22 16:23:00 +02:00
parent 3af490522e
commit 1ffd7ea9d6
5 changed files with 43 additions and 12 deletions

View File

@ -54,7 +54,7 @@
</div>
<div class="join-btn-container">
<button mat-flat-button (click)="joinSession()" id="join-button">
<button mat-flat-button (click)="join()" id="join-button">
{{ 'PREJOIN.JOIN' | translate }}
</button>
</div>

View File

@ -123,7 +123,7 @@ export class PreJoinComponent implements OnInit, OnDestroy {
this.cdkSrv.setSelector('#prejoin-container');
}
joinSession() {
join() {
if (this.showParticipantName && !this.participantName) {
this._error = this.translateService.translate('PREJOIN.NICKNAME_REQUIRED');
return;
@ -143,7 +143,7 @@ export class PreJoinComponent implements OnInit, OnDestroy {
}
onEnterPressed() {
this.joinSession();
this.join();
}
private subscribeToPrejoinDirectives() {

View File

@ -616,13 +616,44 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
/**
* @internal
* Handles the ready-to-join event, initializing the room and managing the prejoin flow.
* This method coordinates the transition from prejoin state to actual room joining.
*/
_onReadyToJoin() {
this.openviduService.initRoom();
const participantName = this.latestParticipantName;
if (participantName) this.onTokenRequested.emit(participantName);
// Emits onReadyToJoin event only if prejoin page has been shown
if (this.showPrejoin) this.onReadyToJoin.emit();
_onReadyToJoin(): void {
this.log.d('Ready to join - initializing room and handling prejoin flow');
try {
// Always initialize the room when ready to join
this.openviduService.initRoom();
const participantName = this.latestParticipantName;
const wasShowingPrejoin = this.showPrejoin;
if (this.isRoomReady) {
// Room is ready, hide prejoin and proceed
this.log.d('Room is ready, proceeding to join');
this.showPrejoin = false;
} else {
// Room not ready, request token if we have a participant name
if (participantName) {
this.log.d(`Requesting token for participant: ${participantName}`);
this.onTokenRequested.emit(participantName);
} else {
this.log.w('No participant name available when requesting token');
}
}
// Emit onReadyToJoin event only if prejoin page was actually shown
// This ensures the event semantics are correct
if (wasShowingPrejoin) {
this.log.d('Emitting onReadyToJoin event (prejoin was shown)');
this.onReadyToJoin.emit();
}
} catch (error) {
this.log.e('Error during ready to join process', error);
// Could emit an error event or handle gracefully based on requirements
}
}
/**
* @internal
@ -644,7 +675,7 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
this.openviduService.initializeAndSetToken(token, livekitUrl);
this.log.d('Token has been successfully set. Room is ready to join');
this.isRoomReady = true;
this.showPrejoin = false;
this.showPrejoin = this.libService.showPrejoin();
} catch (error) {
this.log.e('Error trying to set token', error);
this._tokenError = error;

View File

@ -590,7 +590,7 @@ export class PrejoinDirective implements OnDestroy {
* @ignore
*/
update(value: boolean) {
if (this.libService.isPrejoin() !== value) {
if (this.libService.showPrejoin() !== value) {
this.libService.setPrejoin(value);
}
}

View File

@ -214,7 +214,7 @@ export class OpenViduComponentsConfigService {
this.prejoinDisplayParticipantName.next(prejoinDisplayParticipantName);
}
isPrejoin(): boolean {
showPrejoin(): boolean {
return this.prejoin.getValue();
}