Better handling of backlight dimming (useDimmer=true)

This commit is contained in:
Chrystian Huot 2020-05-16 10:39:47 -04:00
parent 3670f4bc0a
commit b1871695fb
2 changed files with 33 additions and 17 deletions

View file

@ -216,7 +216,7 @@
<div *ngIf="config?.useLed" class="rdio-status" fxLayout="row" fxLayoutAlign="end">
<span class="rdio-led" [ngClass]="ledClass"></span>
</div>
<div class="rdio-display" [ngClass]="{ idle: config?.useDimmer && !dimmerDelay }" (dblclick)="toggleFullscreen()">
<div class="rdio-display" [ngClass]="{ idle: !config || (config?.useDimmer && !dimmerDelay) }" (dblclick)="toggleFullscreen()">
<div class="rdio-display-row margin" fxLayout="row" fxLayoutAlign="space-between">
<div>
<span>

View file

@ -150,6 +150,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.avoid(options);
this.updateDimmer();
}
}
@ -178,6 +180,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.holdSystem();
this.updateDimmer();
}
}
@ -187,6 +191,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.holdTalkgroup();
this.updateDimmer();
}
}
@ -196,6 +202,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.liveFeed();
this.updateDimmer();
}
}
@ -359,6 +367,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
if ('time' in event) {
this.callTime = event.time;
this.updateDimmer();
}
this.updateDisplay();
@ -395,6 +405,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.pause();
this.updateDimmer();
}
}
@ -408,6 +420,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.replay();
this.updateDimmer();
}
}
@ -492,6 +506,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
} else {
this.appRdioScannerService.skip(nodelay);
this.updateDimmer();
}
}
@ -574,6 +590,22 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
return call;
}
private updateDimmer(): void {
if (this.config?.useDimmer) {
if (this.dimmerDelay) {
clearTimeout(this.dimmerDelay);
}
this.dimmerDelay = setTimeout(() => {
this.dimmerDelay = undefined;
this.ngChangeDetectorRef.detectChanges();
}, 4000);
}
this.ngChangeDetectorRef.detectChanges();
}
private updateDisplay(time = this.callTime): void {
if (this.call) {
this.callProgress = new Date(this.call.dateTime);
@ -645,22 +677,6 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
this.ledClass = `${this.ledClass} ${this.call.systemData.led}`;
}
const setDimmer = () => {
if (this.config?.useDimmer) {
if (this.dimmerDelay) {
clearTimeout(this.dimmerDelay);
}
this.dimmerDelay = setTimeout(() => {
this.dimmerDelay = undefined;
this.ngChangeDetectorRef.detectChanges();
}, 3000);
}
};
setDimmer();
this.ngChangeDetectorRef.detectChanges();
}
}