From 782af55fe0c12d7f00e941443be588ee657d56d3 Mon Sep 17 00:00:00 2001 From: ztimson Date: Mon, 2 Sep 2019 21:25:22 -0400 Subject: [PATCH] dont show calibration snackbar if already open --- src/app/views/map/map.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/views/map/map.component.ts b/src/app/views/map/map.component.ts index 516cdfb..e313a2e 100644 --- a/src/app/views/map/map.component.ts +++ b/src/app/views/map/map.component.ts @@ -23,6 +23,8 @@ import {Nouns} from "../../nounes"; animations: [flyInRight, flyOutRight] }) export class MapComponent implements OnDestroy, OnInit { + private calibration; + code: string; drawColor = '#ff4141'; map: MapService; @@ -125,7 +127,7 @@ export class MapComponent implements OnDestroy, OnInit { // Request calibration if needed this.physicsService.requireCalibration.subscribe(() => { - this.snackBar.open('Compass requires calibration', 'calibrate', { + if(!this.calibration) this.snackBar.open('Compass requires calibration', 'calibrate', { duration: 5000, panelClass: 'bg-warning,text-white' }).onAction().subscribe(() => this.startCalibrating()); @@ -163,8 +165,11 @@ export class MapComponent implements OnDestroy, OnInit { } startCalibrating = (menuItem?) => { - let calibration = this.bottomSheet.open(CalibrateComponent, {hasBackdrop: false, disableClose: true}); - this.sub = calibration.afterDismissed().pipe(finalize(() => calibration.dismiss()), filter(menuItem => !!menuItem)).subscribe(() => menuItem.enabled = false); + this.calibration = this.bottomSheet.open(CalibrateComponent, {hasBackdrop: false, disableClose: true}); + this.sub = this.calibration.afterDismissed().pipe(finalize(() => { + this.calibration.dismiss(); + this.calibration = null; + }), filter(menuItem => !!menuItem)).subscribe(() => menuItem.enabled = false); }; startCircle = menuItem => {