Fix config cleaner

This commit is contained in:
Farkas József
2016-12-13 22:58:18 +01:00
parent cde127ecc2
commit 3380a9d514
2 changed files with 9 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;