mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 08:33:00 -06:00
Fix drifting clock on mobile devices
This commit is contained in:
parent
4b23284a83
commit
b046108d26
|
|
@ -116,7 +116,7 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
|
|||
|
||||
@ViewChild('password', { read: MatInput, static: true }) private authPassword: MatInput;
|
||||
|
||||
private clockInterval: any;
|
||||
private clockRefresh: any;
|
||||
|
||||
@ViewChild(MatPaginator, { static: true }) private searchFormPaginator: MatPaginator;
|
||||
|
||||
|
|
@ -216,8 +216,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
|
|||
|
||||
// stop the realtime clock
|
||||
|
||||
if (this.clockInterval) {
|
||||
clearInterval(this.clockInterval);
|
||||
if (this.clockRefresh) {
|
||||
clearTimeout(this.clockRefresh);
|
||||
}
|
||||
|
||||
// terminate our live event emitter
|
||||
|
|
@ -228,17 +228,15 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit {
|
|||
ngOnInit() {
|
||||
// initialize the realtime clock
|
||||
|
||||
setTimeout(() => {
|
||||
const setClock = () => {
|
||||
this.clock = new Date();
|
||||
|
||||
this.clockRefresh = setTimeout(() => setClock(), (60 - this.clock.getSeconds()) * 1000);
|
||||
|
||||
this.ngChangeDetectorRef.markForCheck();
|
||||
};
|
||||
|
||||
this.clockInterval = setInterval(() => {
|
||||
this.clock = new Date();
|
||||
|
||||
this.ngChangeDetectorRef.detectChanges();
|
||||
}, 60 * 1000);
|
||||
}, (60 - new Date().getSeconds()) * 1000);
|
||||
setClock();
|
||||
|
||||
// subscribe to events
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue