From a0e23cd4a727397611d070c9a691333e19673238 Mon Sep 17 00:00:00 2001 From: juancarmore Date: Sat, 19 Jul 2025 20:00:07 +0200 Subject: [PATCH] Remove MEETING_ENDED event and always send LEFT event with proper reason --- .../pages/video-room/video-room.component.ts | 31 ++++++------------- .../tests/e2e/core/events.test.ts | 12 +++---- testapp/public/ts/webcomponent.ts | 4 --- typings/src/webcomponent/event.model.ts | 8 ----- 4 files changed, 14 insertions(+), 41 deletions(-) diff --git a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts index f4b6f9e..8efdf95 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts @@ -332,29 +332,18 @@ export class VideoRoomComponent implements OnInit { leftReason = LeftEventReason.MEETING_ENDED_BY_SELF; } - // Send LEFT or MEETING_ENDED event to the parent component - let message: WebComponentOutboundEventMessage; - if (event.reason === ParticipantLeftReason.ROOM_DELETED) { - message = { - event: WebComponentEvent.MEETING_ENDED, - payload: { - roomId: event.roomName, - endedByMe: this.meetingEndedByMe - } - } as WebComponentOutboundEventMessage; - } else { - message = { - event: WebComponentEvent.LEFT, - payload: { - roomId: event.roomName, - participantName: event.participantName, - reason: leftReason - } - } as WebComponentOutboundEventMessage; - } - + // Send LEFT event to the parent component + const message: WebComponentOutboundEventMessage = { + event: WebComponentEvent.LEFT, + payload: { + roomId: event.roomName, + participantName: event.participantName, + reason: leftReason + } + }; this.wcManagerService.sendMessageToParent(message); + // Remove the moderator secret from session storage if the participant left for a reason other than browser unload if (event.reason !== ParticipantLeftReason.BROWSER_UNLOAD) { this.sessionStorageService.removeModeratorSecret(event.roomName); } diff --git a/frontend/webcomponent/tests/e2e/core/events.test.ts b/frontend/webcomponent/tests/e2e/core/events.test.ts index 5e28850..cd01da0 100644 --- a/frontend/webcomponent/tests/e2e/core/events.test.ts +++ b/frontend/webcomponent/tests/e2e/core/events.test.ts @@ -37,7 +37,7 @@ test.describe('Web Component E2E Tests', () => { }); subscribedToAppErrors = true; } - + await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix); participantName = `P-${Math.random().toString(36).substring(2, 9)}`; }); @@ -91,19 +91,15 @@ test.describe('Web Component E2E Tests', () => { expect(leftElements.length).toBe(1); }); - test('should successfully join to room and receive MEETING_ENDED event when using end meeting command', async ({ + test('should successfully join to room and receive LEFT event when using end meeting command', async ({ page }) => { await joinRoomAs('moderator', participantName, page); await page.click('#end-meeting-btn'); - await page.waitForSelector('.event-MEETING_ENDED'); - const meetingEndedElements = await page.locator('.event-MEETING_ENDED').all(); + await page.waitForSelector('.event-LEFT'); + const meetingEndedElements = await page.locator('.event-LEFT').all(); expect(meetingEndedElements.length).toBe(1); - - // Check LEFT event does not exist - const leftEventElements = await page.locator('.event-LEFT').all(); - expect(leftEventElements.length).toBe(0); }); }); }); diff --git a/testapp/public/ts/webcomponent.ts b/testapp/public/ts/webcomponent.ts index 2862b17..f7e8039 100644 --- a/testapp/public/ts/webcomponent.ts +++ b/testapp/public/ts/webcomponent.ts @@ -202,10 +202,6 @@ const listenWebComponentEvents = () => { console.log('LEFT event received:', event); addEventToLog('LEFT', JSON.stringify(event)); }); - meet.on('MEETING_ENDED', (event: CustomEvent) => { - console.log('MEETING_ENDED event received:', event); - addEventToLog('MEETING_ENDED', JSON.stringify(event)); - }); meet.on('CLOSED', (event: CustomEvent) => { console.log('CLOSED event received:', event); addEventToLog('CLOSED', JSON.stringify(event)); diff --git a/typings/src/webcomponent/event.model.ts b/typings/src/webcomponent/event.model.ts index e230bdc..ddceda7 100644 --- a/typings/src/webcomponent/event.model.ts +++ b/typings/src/webcomponent/event.model.ts @@ -16,10 +16,6 @@ export enum WebComponentEvent { * Event emitted when the local participant leaves the room. */ LEFT = 'LEFT', - /** - * Event emitted when a moderator ends the meeting. - */ - MEETING_ENDED = 'MEETING_ENDED', /** * Event emitted when the application is closed. */ @@ -59,10 +55,6 @@ export interface WebComponentEventPayloads { participantName: string; reason: LeftEventReason; }; - [WebComponentEvent.MEETING_ENDED]: { - roomId: string; - endedByMe: boolean; // Indicates if the meeting was ended by the local participant - }; } /**