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