ov-components: Prevent prejoin from showing again after user initiates join process

master
Carlos Santos 2025-07-22 17:45:03 +02:00
parent fabeaf1471
commit 8af9f75a10
1 changed files with 24 additions and 4 deletions

View File

@ -390,6 +390,12 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
*/
showPrejoin: boolean = true;
/**
* @internal
* Tracks if user has initiated the join process to prevent prejoin from showing again
*/
private hasUserInitiatedJoin: boolean = false;
/**
* @internal
*/
@ -623,11 +629,13 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
this.log.d('Ready to join - initializing room and handling prejoin flow');
try {
// Mark that user has initiated the join process
this.hasUserInitiatedJoin = true;
// 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
@ -643,13 +651,14 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
}
}
const wasPrejoinShown = this.showPrejoin;
// Emit onReadyToJoin event only if prejoin page was actually shown
// This ensures the event semantics are correct
if (wasShowingPrejoin) {
if (wasPrejoinShown) {
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
@ -660,6 +669,8 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
*/
_onParticipantLeft(event: ParticipantLeftEvent) {
this.isRoomReady = false;
// Reset join initiation flag to allow prejoin to show again if needed
this.hasUserInitiatedJoin = false;
this.onParticipantLeft.emit(event);
}
@ -675,7 +686,16 @@ 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 = this.libService.showPrejoin();
// Only update showPrejoin if user hasn't initiated join process yet
// This prevents prejoin from showing again after user clicked join
if (!this.hasUserInitiatedJoin) {
this.showPrejoin = this.libService.showPrejoin();
} else {
// User has initiated join, proceed to hide prejoin and continue
this.log.d('User has initiated join, hiding prejoin and proceeding');
this.showPrejoin = false;
}
} catch (error) {
this.log.e('Error trying to set token', error);
this._tokenError = error;