mirror of https://github.com/OpenVidu/openvidu.git
ov-components: remove ServiceConfigService and update components to use LayoutService directly
parent
7315360fbc
commit
5fba250b1d
|
@ -19,7 +19,6 @@ import { ParticipantService } from '../../services/participant/participant.servi
|
|||
import { CdkDrag } from '@angular/cdk/drag-drop';
|
||||
import { PanelService } from '../../services/panel/panel.service';
|
||||
import { GlobalConfigService } from '../../services/config/global-config.service';
|
||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
||||
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
|
||||
|
||||
/**
|
||||
|
@ -80,21 +79,18 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
private resizeTimeout: NodeJS.Timeout;
|
||||
private videoIsAtRight: boolean = false;
|
||||
private lastLayoutWidth: number = 0;
|
||||
private layoutService: LayoutService;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
constructor(
|
||||
private serviceConfig: ServiceConfigService,
|
||||
private layoutService: LayoutService,
|
||||
private panelService: PanelService,
|
||||
private participantService: ParticipantService,
|
||||
private globalService: GlobalConfigService,
|
||||
private directiveService: OpenViduComponentsConfigService,
|
||||
private cd: ChangeDetectorRef
|
||||
) {
|
||||
this.layoutService = this.serviceConfig.getLayoutService();
|
||||
}
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscribeToParticipants();
|
||||
|
|
|
@ -47,7 +47,6 @@ import {
|
|||
Track
|
||||
} from 'livekit-client';
|
||||
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -108,10 +107,9 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
private updateLayoutInterval: NodeJS.Timeout;
|
||||
private captionLanguageSubscription: Subscription;
|
||||
private log: ILogger;
|
||||
private layoutService: LayoutService;
|
||||
|
||||
constructor(
|
||||
private serviceConfig: ServiceConfigService,
|
||||
private layoutService: LayoutService,
|
||||
private actionService: ActionService,
|
||||
private openviduService: OpenViduService,
|
||||
private participantService: ParticipantService,
|
||||
|
@ -127,7 +125,6 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
private cd: ChangeDetectorRef
|
||||
) {
|
||||
this.log = this.loggerSrv.get('SessionComponent');
|
||||
this.layoutService = this.serviceConfig.getLayoutService();
|
||||
}
|
||||
|
||||
@HostListener('window:beforeunload')
|
||||
|
|
|
@ -23,11 +23,11 @@ export class CaptionsSettingComponent implements OnInit, OnDestroy {
|
|||
private captionsStatusSubs: Subscription;
|
||||
private sttStatusSubs: Subscription;
|
||||
|
||||
private layoutService: LayoutService;
|
||||
|
||||
constructor(private serviceConfig: ServiceConfigService, private captionService: CaptionService, private openviduService: OpenViduService) {
|
||||
this.layoutService = this.serviceConfig.getLayoutService();
|
||||
}
|
||||
constructor(
|
||||
private layoutService: LayoutService,
|
||||
private captionService: CaptionService,
|
||||
private openviduService: OpenViduService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// this.isOpenViduPro = this.openviduService.isOpenViduPro();
|
||||
|
|
|
@ -7,7 +7,6 @@ import { LayoutService } from '../../services/layout/layout.service';
|
|||
import { ParticipantService } from '../../services/participant/participant.service';
|
||||
import { Track } from 'livekit-client';
|
||||
import { ParticipantTrackPublication } from '../../models/participant.model';
|
||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
||||
|
||||
/**
|
||||
* The **StreamComponent** is hosted inside of the {@link LayoutComponent}.
|
||||
|
@ -98,18 +97,15 @@ export class StreamComponent implements OnInit, OnDestroy {
|
|||
private videoControlsSub: Subscription;
|
||||
private readonly HOVER_TIMEOUT = 3000;
|
||||
|
||||
private layoutService: LayoutService;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
constructor(
|
||||
private serviceConfig: ServiceConfigService,
|
||||
private layoutService: LayoutService,
|
||||
private participantService: ParticipantService,
|
||||
private cdkSrv: CdkOverlayService,
|
||||
private libService: OpenViduComponentsConfigService
|
||||
) {
|
||||
this.layoutService = this.serviceConfig.getLayoutService();
|
||||
}
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscribeToStreamDirectives();
|
||||
|
|
|
@ -49,7 +49,6 @@ import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.servic
|
|||
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
||||
import { Room, RoomEvent } from 'livekit-client';
|
||||
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';
|
||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
||||
|
||||
/**
|
||||
* The **ToolbarComponent** is hosted inside of the {@link VideoconferenceComponent}.
|
||||
|
@ -349,13 +348,12 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
private additionalButtonsPositionSub: Subscription;
|
||||
private fullscreenChangeSubscription: Subscription;
|
||||
private currentWindowHeight = window.innerHeight;
|
||||
private layoutService: LayoutService;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
constructor(
|
||||
private serviceConfig: ServiceConfigService,
|
||||
private layoutService: LayoutService,
|
||||
private documentService: DocumentService,
|
||||
private chatService: ChatService,
|
||||
private panelService: PanelService,
|
||||
|
@ -374,7 +372,6 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
private cdkOverlayService: CdkOverlayService
|
||||
) {
|
||||
this.log = this.loggerSrv.get('ToolbarComponent');
|
||||
this.layoutService = this.serviceConfig.getLayoutService();
|
||||
}
|
||||
/**
|
||||
* @ignore
|
||||
|
|
|
@ -3,7 +3,6 @@ import { ParticipantProperties } from '../models/participant.model';
|
|||
export interface OpenViduComponentsConfig {
|
||||
production?: boolean;
|
||||
participantFactory?: ParticipantFactoryFunction;
|
||||
services?: any;
|
||||
}
|
||||
|
||||
export type ParticipantFactoryFunction = (props: ParticipantProperties) => any;
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import { Injectable, Inject, Injector, Optional } from '@angular/core';
|
||||
import { LayoutService } from '../layout/layout.service';
|
||||
import { OpenViduComponentsConfig } from '../../config/openvidu-components-angular.config';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ServiceConfigService {
|
||||
private configuration: OpenViduComponentsConfig;
|
||||
|
||||
constructor(
|
||||
@Optional() private injector: Injector,
|
||||
@Inject('OPENVIDU_COMPONENTS_CONFIG') config: OpenViduComponentsConfig
|
||||
) {
|
||||
this.configuration = config;
|
||||
}
|
||||
|
||||
getLayoutService(): LayoutService {
|
||||
return this.getServiceSafely<LayoutService>('LayoutService', LayoutService);
|
||||
}
|
||||
|
||||
private getService<T>(key: string): T {
|
||||
const service = this.configuration.services ? this.configuration.services[key] : null;
|
||||
if (!service) {
|
||||
throw new Error(`No service registered with key ${key}`);
|
||||
}
|
||||
return this.injector.get(service) as T;
|
||||
}
|
||||
|
||||
private getServiceSafely<T>(key: string, fallback: new (...args: any[]) => T): T {
|
||||
try {
|
||||
return this.getService<T>(key);
|
||||
} catch {
|
||||
return this.injector.get(fallback);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue