Merge pull request #5055 from tsiegleauq/fix-projector

Fix flickering projector button in lists
This commit is contained in:
Emanuel Schütze 2019-09-24 22:04:30 +02:00 committed by GitHub
commit 7f49ead439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -1,19 +1,19 @@
<ng-container *osPerms="'core.can_manage_projector'"> <ng-container *osPerms="'core.can_manage_projector'">
<button <button
type="button" type="button"
*ngIf="!text && !menuItem" class="projector-active"
mat-mini-fab mat-mini-fab
(click)="onClick($event)" (click)="onClick($event)"
[ngClass]="isProjected ? 'projector-active' : 'projector-inactive'" *ngIf="!text && !menuItem && checkIsProjected()"
> >
<mat-icon>videocam</mat-icon> <mat-icon>videocam</mat-icon>
</button> </button>
<button <button
type="button" type="button"
*ngIf="text && !menuItem" class="projector-inactive"
mat-button mat-mini-fab
(click)="onClick($event)" (click)="onClick($event)"
[ngClass]="isProjected ? 'projector-active' : 'projector-inactive'" *ngIf="!text && !menuItem && !checkIsProjected()"
> >
<mat-icon>videocam</mat-icon> <mat-icon>videocam</mat-icon>
{{ text | translate }} {{ text | translate }}
@ -23,7 +23,7 @@
*ngIf="menuItem" *ngIf="menuItem"
mat-menu-item mat-menu-item
(click)="onClick()" (click)="onClick()"
[ngClass]="isProjected ? 'projector-active' : 'projector-inactive'" [ngClass]="checkIsProjected() ? 'projector-active' : 'projector-inactive'"
> >
<mat-icon>videocam</mat-icon> <mat-icon>videocam</mat-icon>
{{ text || 'Project' | translate }} {{ text || 'Project' | translate }}

View File

@ -38,8 +38,6 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy {
return this._object; return this._object;
} }
public isProjected = false;
@Input() @Input()
public set object(obj: Projectable | ProjectorElementBuildDeskriptor) { public set object(obj: Projectable | ProjectorElementBuildDeskriptor) {
if (isProjectable(obj) || isProjectorElementBuildDeskriptor(obj)) { if (isProjectable(obj) || isProjectorElementBuildDeskriptor(obj)) {
@ -80,17 +78,11 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy {
* Initialization function * Initialization function
*/ */
public ngOnInit(): void { public ngOnInit(): void {
this.isProjected = this.checkIsProjected();
this.projectorRepoSub = this.projectorRepo this.projectorRepoSub = this.projectorRepo
.getGeneralViewModelObservable() .getGeneralViewModelObservable()
.pipe(distinctUntilChanged()) .pipe(distinctUntilChanged())
.subscribe(() => { .subscribe(() => {
const isProjected = this.checkIsProjected(); this.changeEvent.next();
if (this.isProjected !== isProjected) {
this.isProjected = isProjected;
this.changeEvent.next();
}
}); });
} }