diff --git a/frontend/projects/shared-meet-components/src/lib/guards/application-mode.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/application-mode.guard.ts deleted file mode 100644 index efcea58..0000000 --- a/frontend/projects/shared-meet-components/src/lib/guards/application-mode.guard.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { inject } from '@angular/core'; -import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router'; -import { ApplicationMode } from '@lib/models'; -import { AppDataService, WebComponentManagerService } from '@lib/services'; - -export const applicationModeGuard: CanActivateFn = (_route: ActivatedRouteSnapshot, _state: RouterStateSnapshot) => { - const appDataService = inject(AppDataService); - const commandsManagerService = inject(WebComponentManagerService); - - const isRequestedFromIframe = window.self !== window.top; - - const applicationMode = isRequestedFromIframe ? ApplicationMode.EMBEDDED : ApplicationMode.STANDALONE; - appDataService.setApplicationMode(applicationMode); - - if (appDataService.isEmbeddedMode()) { - // Start listening for commands from the iframe - commandsManagerService.startCommandsListener(); - } - - return true; -}; diff --git a/frontend/projects/shared-meet-components/src/lib/guards/index.ts b/frontend/projects/shared-meet-components/src/lib/guards/index.ts index 7e93399..1d125a2 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/index.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/index.ts @@ -1,4 +1,3 @@ -export * from './application-mode.guard'; export * from './auth.guard'; export * from './extract-query-params.guard'; export * from './moderator-secret.guard'; diff --git a/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts b/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts index 6e6217b..0b1136b 100644 --- a/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts +++ b/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts @@ -1,6 +1,5 @@ import { Routes } from '@angular/router'; import { - applicationModeGuard, checkParticipantRoleAndAuthGuard, checkRecordingAuthGuard, checkUserAuthenticatedGuard, @@ -18,11 +17,11 @@ import { ErrorComponent, LoginComponent, OverviewComponent, - UsersPermissionsComponent, RecordingsComponent, RoomRecordingsComponent, RoomsComponent, RoomWizardComponent, + UsersPermissionsComponent, VideoRoomComponent, ViewRecordingComponent } from '@lib/pages'; @@ -36,16 +35,13 @@ export const baseRoutes: Routes = [ { path: 'room/:room-id', component: VideoRoomComponent, - canActivate: [ - runGuardsSerially(applicationModeGuard, extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard) - ] + canActivate: [runGuardsSerially(extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard)] }, { path: 'room/:room-id/recordings', component: RoomRecordingsComponent, canActivate: [ runGuardsSerially( - applicationModeGuard, extractRecordingQueryParamsGuard, checkParticipantRoleAndAuthGuard, validateRecordingAccessGuard, @@ -56,7 +52,7 @@ export const baseRoutes: Routes = [ { path: 'recording/:recording-id', component: ViewRecordingComponent, - canActivate: [runGuardsSerially(applicationModeGuard, checkRecordingAuthGuard)] + canActivate: [checkRecordingAuthGuard] }, { path: 'disconnected', component: DisconnectedComponent }, { path: 'error', component: ErrorComponent }, diff --git a/frontend/projects/shared-meet-components/src/lib/services/app-data.service.ts b/frontend/projects/shared-meet-components/src/lib/services/app-data.service.ts index 4aac6ae..4178a0f 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/app-data.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/app-data.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { AppData, ApplicationMode, Edition } from '@lib/models'; +import { WebComponentManagerService } from '@lib/services'; @Injectable({ providedIn: 'root' @@ -11,9 +12,20 @@ export class AppDataService { version: '' }; - setApplicationMode(mode: ApplicationMode): void { - console.log(`Starting application in ${mode} mode`); - this.appData.mode = mode; + constructor(protected wcManagerService: WebComponentManagerService) { + this.setApplicationMode(); + } + + private setApplicationMode(): void { + const isRequestedFromIframe = window.self !== window.top; + const appMode = isRequestedFromIframe ? ApplicationMode.EMBEDDED : ApplicationMode.STANDALONE; + this.appData.mode = appMode; + console.log(`Starting application in ${appMode} mode`); + + if (this.isEmbeddedMode()) { + // Initialize the WebComponentManagerService only in embedded mode + this.wcManagerService.initialize(); + } } isEmbeddedMode(): boolean {