Fix flickering projector button in lists

...
This commit is contained in:
Sean Engelhardt 2019-09-24 21:31:51 +02:00
parent 534f2d1835
commit dc60d1254b
2 changed files with 7 additions and 15 deletions

View File

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

View File

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