From 76c51af4efe018fb4ed458c0d138846c76960afa Mon Sep 17 00:00:00 2001 From: csantosm <4a.santos@gmail.com> Date: Fri, 4 Feb 2022 11:26:27 +0100 Subject: [PATCH] openvidu-component: Refactored components --- .../src/lib/components/layout/layout.component.ts | 11 +---------- .../src/lib/components/session/session.component.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts index abf429c1..81de313a 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, ComponentRef, ContentChild, Directive, Input, OnDestroy, OnInit, TemplateRef, Type, ViewChild, ViewContainerRef } from '@angular/core'; +import { AfterViewInit, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core'; import { Subscription } from 'rxjs'; import { ParticipantService } from '../../services/participant/participant.service'; import { ParticipantAbstractModel } from '../../models/participant.model'; @@ -10,25 +10,16 @@ import { LayoutService } from '../../services/layout/layout.service'; styleUrls: ['./layout.component.css'] }) export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit { - // @ContentChild('customLocalParticipant', { read: TemplateRef }) customLocalParticipantTemplate: TemplateRef; - // @ContentChild('customRemoteParticipants', { read: TemplateRef }) customRemoteParticipantsTemplate: TemplateRef; - @ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef; - - - localParticipant: ParticipantAbstractModel; remoteParticipants: ParticipantAbstractModel[] = []; protected localParticipantSubs: Subscription; protected remoteParticipantsSubs: Subscription; - protected updateLayoutInterval: NodeJS.Timer; constructor(protected layoutService: LayoutService, protected participantService: ParticipantService) {} ngOnInit(): void { - this.layoutService.initialize(); - this.subscribeToUsers(); } diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts index d2251ece..e70fefcd 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts @@ -1,4 +1,4 @@ -import { Component, ContentChild, EventEmitter, HostListener, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; +import { AfterViewInit, Component, ContentChild, EventEmitter, HostListener, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; import { Subscriber, Session, StreamEvent, StreamPropertyChangedEvent, SessionDisconnectedEvent, ConnectionEvent } from 'openvidu-browser'; import { VideoType } from '../../models/video-type.model'; @@ -23,7 +23,7 @@ import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.ser templateUrl: './session.component.html', styleUrls: ['./session.component.css'] }) -export class SessionComponent implements OnInit { +export class SessionComponent implements OnInit, AfterViewInit { @ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate: TemplateRef; @ContentChild('layout', { read: TemplateRef }) layoutTemplate: TemplateRef; @ContentChild('panel', { read: TemplateRef }) panelTemplate: TemplateRef; @@ -84,7 +84,6 @@ export class SessionComponent implements OnInit { } async ngOnInit() { - // this.layoutService.initialize(); if (this.webrtcService.getWebcamSession() === null) { this.webrtcService.initialize(); @@ -113,6 +112,12 @@ export class SessionComponent implements OnInit { this._session.emit(this.session); } + ngAfterViewInit(): void { + this.layoutService.initialize(); + this.layoutService.update(); + + } + ngOnDestroy() { // Reconnecting session is received in Firefox // To avoid 'Connection lost' message uses session.off()