dont show calibration snackbar if already open
This commit is contained in:
parent
72d5567c4e
commit
782af55fe0
@ -23,6 +23,8 @@ import {Nouns} from "../../nounes";
|
|||||||
animations: [flyInRight, flyOutRight]
|
animations: [flyInRight, flyOutRight]
|
||||||
})
|
})
|
||||||
export class MapComponent implements OnDestroy, OnInit {
|
export class MapComponent implements OnDestroy, OnInit {
|
||||||
|
private calibration;
|
||||||
|
|
||||||
code: string;
|
code: string;
|
||||||
drawColor = '#ff4141';
|
drawColor = '#ff4141';
|
||||||
map: MapService;
|
map: MapService;
|
||||||
@ -125,7 +127,7 @@ export class MapComponent implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
// Request calibration if needed
|
// Request calibration if needed
|
||||||
this.physicsService.requireCalibration.subscribe(() => {
|
this.physicsService.requireCalibration.subscribe(() => {
|
||||||
this.snackBar.open('Compass requires calibration', 'calibrate', {
|
if(!this.calibration) this.snackBar.open('Compass requires calibration', 'calibrate', {
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
panelClass: 'bg-warning,text-white'
|
panelClass: 'bg-warning,text-white'
|
||||||
}).onAction().subscribe(() => this.startCalibrating());
|
}).onAction().subscribe(() => this.startCalibrating());
|
||||||
@ -163,8 +165,11 @@ export class MapComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startCalibrating = (menuItem?) => {
|
startCalibrating = (menuItem?) => {
|
||||||
let calibration = this.bottomSheet.open(CalibrateComponent, {hasBackdrop: false, disableClose: true});
|
this.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.sub = this.calibration.afterDismissed().pipe(finalize(() => {
|
||||||
|
this.calibration.dismiss();
|
||||||
|
this.calibration = null;
|
||||||
|
}), filter(menuItem => !!menuItem)).subscribe(() => menuItem.enabled = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
startCircle = menuItem => {
|
startCircle = menuItem => {
|
||||||
|
Loading…
Reference in New Issue
Block a user