diff --git a/src/store/storage/index.ts b/src/store/storage/index.ts index a7a29312..da4b555d 100644 --- a/src/store/storage/index.ts +++ b/src/store/storage/index.ts @@ -44,7 +44,7 @@ export class DataStorage { } // Local storage else { - this._environment = new Local(); + this._environment = new Local(this.uhkConfiguration.dataModelVersion); } } @@ -88,7 +88,7 @@ export class DataStorage { getConfiguration(): UhkConfiguration { let config: UhkConfiguration = this._environment.getConfig(); - if (!config || config.dataModelVersion !== this.uhkConfiguration.dataModelVersion) { + if (!config) { config = this.uhkConfiguration; } return config; diff --git a/src/store/storage/local.ts b/src/store/storage/local.ts index c5d73be8..3fe2c64a 100644 --- a/src/store/storage/local.ts +++ b/src/store/storage/local.ts @@ -2,14 +2,17 @@ import { UhkConfiguration } from '../../config-serializer/config-items/UhkConfig export class Local { - constructor() { } + constructor(private dataModelVersion: number) { } getConfig(): UhkConfiguration { - let configJson = localStorage.getItem('config'); + let configJsonString = localStorage.getItem('config'); let config: UhkConfiguration; - if (configJson) { - config = new UhkConfiguration().fromJsObject(JSON.parse(configJson)); + if (configJsonString) { + const configJsonObject = JSON.parse(configJsonString); + if (configJsonObject.dataModelVersion === this.dataModelVersion) { + config = new UhkConfiguration().fromJsObject(configJsonObject); + } } return config;