mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-16 01:43: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 subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
private visibilityChangeListener = () => this.ngDetectChanges();
|
private visibilityChangeListener = () => this.syncClock();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private appRdioScannerService: AppRdioScannerService,
|
private appRdioScannerService: AppRdioScannerService,
|
||||||
|
|
@ -224,15 +224,7 @@ export class AppRdioScannerComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
// initialize the realtime clock
|
// initialize the realtime clock
|
||||||
|
|
||||||
const setClock = () => {
|
this.syncClock();
|
||||||
this.clock = new Date();
|
|
||||||
|
|
||||||
this.clockRefresh = setTimeout(() => setClock(), (60 - this.clock.getSeconds()) * 1000);
|
|
||||||
|
|
||||||
this.ngDetectChanges();
|
|
||||||
};
|
|
||||||
|
|
||||||
setClock();
|
|
||||||
|
|
||||||
// subscribe to events
|
// 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 {
|
private transformCall(call: RdioScannerCall): RdioScannerCall {
|
||||||
if (call && Array.isArray(this.config && this.config.systems)) {
|
if (call && Array.isArray(this.config && this.config.systems)) {
|
||||||
call.systemData = this.config?.systems.find((sys) => sys.id === call.system);
|
call.systemData = this.config?.systems.find((sys) => sys.id === call.system);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue