Fix config cleaner
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user