mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Update clock on tab focus
This commit is contained in:
parent
79bdf7b3e7
commit
ca410ce742
|
|
@ -129,7 +129,7 @@ export class AppRdioScannerComponent implements AfterViewInit, OnDestroy {
|
|||
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
private visibilityChangeListener = () => this.ngDetectChanges();
|
||||
private visibilityChangeListener = () => this.syncClock();
|
||||
|
||||
constructor(
|
||||
private appRdioScannerService: AppRdioScannerService,
|
||||
|
|
@ -224,15 +224,7 @@ export class AppRdioScannerComponent implements AfterViewInit, OnDestroy {
|
|||
|
||||
// initialize the realtime clock
|
||||
|
||||
const setClock = () => {
|
||||
this.clock = new Date();
|
||||
|
||||
this.clockRefresh = setTimeout(() => setClock(), (60 - this.clock.getSeconds()) * 1000);
|
||||
|
||||
this.ngDetectChanges();
|
||||
};
|
||||
|
||||
setClock();
|
||||
this.syncClock();
|
||||
|
||||
// subscribe to events
|
||||
|
||||
|
|
@ -783,6 +775,18 @@ export class AppRdioScannerComponent implements AfterViewInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
|
||||
private syncClock(): void {
|
||||
this.clock = new Date();
|
||||
|
||||
if (this.clockRefresh) {
|
||||
clearTimeout(this.clockRefresh);
|
||||
}
|
||||
|
||||
this.clockRefresh = setTimeout(() => this.syncClock(), (60 - this.clock.getSeconds()) * 1000);
|
||||
|
||||
this.ngDetectChanges();
|
||||
};
|
||||
|
||||
private transformCall(call: RdioScannerCall): RdioScannerCall {
|
||||
if (call && Array.isArray(this.config && this.config.systems)) {
|
||||
call.systemData = this.config?.systems.find((sys) => sys.id === call.system);
|
||||
|
|
|
|||
Loading…
Reference in a new issue