mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Added OnPush detection strategy
parent
8ee9d74d3d
commit
948a64c551
|
@ -1,4 +1,4 @@
|
|||
import { AfterViewInit, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, 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';
|
||||
|
@ -8,9 +8,10 @@ import { StreamDirective } from '../../directives/openvidu-angular.directive';
|
|||
@Component({
|
||||
selector: 'ov-layout',
|
||||
templateUrl: './layout.component.html',
|
||||
styleUrls: ['./layout.component.css']
|
||||
styleUrls: ['./layout.component.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
export class LayoutComponent implements OnInit, OnDestroy {
|
||||
@ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef<any>;
|
||||
|
||||
@ContentChild(StreamDirective)
|
||||
|
@ -27,30 +28,33 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
protected localParticipantSubs: Subscription;
|
||||
protected remoteParticipantsSubs: Subscription;
|
||||
|
||||
constructor(protected layoutService: LayoutService, protected participantService: ParticipantService) {}
|
||||
constructor(protected layoutService: LayoutService, protected participantService: ParticipantService, private cd: ChangeDetectorRef) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscribeToUsers();
|
||||
this.layoutService.initialize();
|
||||
this.layoutService.update();
|
||||
}
|
||||
|
||||
ngAfterViewInit() {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.localParticipant = null;
|
||||
this.remoteParticipants = [];
|
||||
if (this.localParticipantSubs) this.localParticipantSubs.unsubscribe();
|
||||
if (this.remoteParticipantsSubs) this.remoteParticipantsSubs.unsubscribe();
|
||||
this.layoutService.clear();
|
||||
}
|
||||
|
||||
protected subscribeToUsers() {
|
||||
this.localParticipantSubs = this.participantService.localParticipantObs.subscribe((p) => {
|
||||
this.localParticipant = p;
|
||||
this.layoutService.update();
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
|
||||
this.remoteParticipantsSubs = this.participantService.remoteParticipantsObs.subscribe((participants) => {
|
||||
this.remoteParticipants = [...participants];
|
||||
this.layoutService.update();
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AfterViewInit, Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ChatMessage } from '../../../models/chat.model';
|
||||
import { MenuType } from '../../../models/menu.model';
|
||||
|
@ -8,7 +8,8 @@ import { SidenavMenuService } from '../../../services/sidenav-menu/sidenav-menu.
|
|||
@Component({
|
||||
selector: 'ov-chat-panel',
|
||||
templateUrl: './chat-panel.component.html',
|
||||
styleUrls: ['./chat-panel.component.css']
|
||||
styleUrls: ['./chat-panel.component.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ChatPanelComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('chatScroll') chatScroll: ElementRef;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
|
||||
import { skip, Subscription } from 'rxjs';
|
||||
import { ChatPanelDirective, ParticipantsPanelDirective } from '../../directives/openvidu-angular.directive';
|
||||
import { MenuType } from '../../models/menu.model';
|
||||
|
@ -7,7 +7,8 @@ import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.ser
|
|||
@Component({
|
||||
selector: 'ov-panel',
|
||||
templateUrl: './panel.component.html',
|
||||
styleUrls: ['./panel.component.css']
|
||||
styleUrls: ['./panel.component.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class PanelComponent implements OnInit {
|
||||
@ContentChild('participantsPanel', { read: TemplateRef }) participantsPanelTemplate: TemplateRef<any>;
|
||||
|
@ -34,7 +35,7 @@ export class PanelComponent implements OnInit {
|
|||
isParticipantsPanelOpened: boolean;
|
||||
isChatPanelOpened: boolean;
|
||||
menuSubscription: Subscription;
|
||||
constructor(protected menuService: SidenavMenuService) {}
|
||||
constructor(protected menuService: SidenavMenuService, private cd: ChangeDetectorRef) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscribeToPanelToggling();
|
||||
|
@ -43,6 +44,7 @@ export class PanelComponent implements OnInit {
|
|||
this.menuSubscription = this.menuService.menuOpenedObs.pipe(skip(1)).subscribe((ev: { opened: boolean; type?: MenuType }) => {
|
||||
this.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT;
|
||||
this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChangeDetectorRef, Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
|
||||
import { ParticipantAbstractModel, ParticipantModel } from '../../../../models/participant.model';
|
||||
import { ParticipantService } from '../../../../services/participant/participant.service';
|
||||
import { SidenavMenuService } from '../../../..//services/sidenav-menu/sidenav-menu.service';
|
||||
|
@ -7,7 +7,8 @@ import { ParticipantPanelItemDirective } from '../../../../directives/openvidu-a
|
|||
@Component({
|
||||
selector: 'ov-participants-panel',
|
||||
templateUrl: './participants-panel.component.html',
|
||||
styleUrls: ['./participants-panel.component.css']
|
||||
styleUrls: ['./participants-panel.component.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ParticipantsPanelComponent implements OnInit {
|
||||
localParticipant: any;
|
||||
|
|
|
@ -4,7 +4,6 @@ import { MatMenuPanel, MatMenuTrigger } from '@angular/material/menu';
|
|||
import { NicknameMatcher } from '../../matchers/nickname.matcher';
|
||||
import { VideoSizeIcon } from '../../models/icon.model';
|
||||
import { ScreenType, VideoType } from '../../models/video-type.model';
|
||||
import { Storage } from '../../models/storage.model';
|
||||
import { DocumentService } from '../../services/document/document.service';
|
||||
import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.service';
|
||||
import { OpenViduService } from '../../services/openvidu/openvidu.service';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, ElementRef, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { FormControl, Validators } from '@angular/forms';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
|
@ -22,7 +22,8 @@ import { ParticipantAbstractModel } from '../../models/participant.model';
|
|||
@Component({
|
||||
selector: 'ov-user-settings',
|
||||
templateUrl: './user-settings.component.html',
|
||||
styleUrls: ['./user-settings.component.css']
|
||||
styleUrls: ['./user-settings.component.css'],
|
||||
// changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class UserSettingsComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('bodyCard') bodyCard: ElementRef;
|
||||
|
|
Loading…
Reference in New Issue