From c9302aae1b4564bfee159aa988ee31287075451e Mon Sep 17 00:00:00 2001 From: Jiri Pokorny Date: Wed, 14 Aug 2024 01:24:25 +0200 Subject: [PATCH] Fixed loading of maxDensity --- projects/planner/src/app/shared/ApplicationSettings.ts | 2 +- projects/planner/src/app/shared/preferences.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/planner/src/app/shared/ApplicationSettings.ts b/projects/planner/src/app/shared/ApplicationSettings.ts index 7202f4a2..da1506b7 100644 --- a/projects/planner/src/app/shared/ApplicationSettings.ts +++ b/projects/planner/src/app/shared/ApplicationSettings.ts @@ -24,6 +24,6 @@ export class ApplicationSettingsService { } public loadFrom(maxDensity: number): void { - this.settings.maxGasDensity = maxDensity || GasDensity.recommendedMaximum; + this.settings.maxGasDensity = maxDensity; } } diff --git a/projects/planner/src/app/shared/preferences.ts b/projects/planner/src/app/shared/preferences.ts index b66b867e..c384732b 100644 --- a/projects/planner/src/app/shared/preferences.ts +++ b/projects/planner/src/app/shared/preferences.ts @@ -12,6 +12,7 @@ import { DiveSetup } from './models'; import { DiveSchedule, DiveSchedules } from './dive.schedules'; import { DashBoardViewState } from './views.model'; import { ApplicationSettingsService } from './ApplicationSettings'; +import { GasDensity } from "scuba-physics"; @Injectable() export class Preferences { @@ -78,7 +79,8 @@ export class Preferences { // first apply units to prevent loading of invalid values this.units.imperialUnits = loaded.options.imperialUnits; this.applyDives(loaded.dives); - this.appSettings.loadFrom(loaded.options.maxDensity); + const loadedDensity = loaded.options.maxDensity || GasDensity.recommendedMaximum; + this.appSettings.loadFrom(loadedDensity); // now we are able to switch the view this.viewSwitch.isComplex = loaded.options.isComplex;