From 961d4b7605f9162d63aaaa7e57e740d691fc10d7 Mon Sep 17 00:00:00 2001 From: Sylwester Wroblewski Date: Thu, 27 Jun 2024 17:22:12 +0200 Subject: [PATCH] Fixed problems with instancesByJsName, IdeSettings state is now saved properly --- src/v1/utils/Compilation/JsImporter.ts | 5 ++++- src/v1/utils/Compilation/SchemaUtils.ts | 9 +++------ src/v1/utils/LocalStorageApi.ts | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/v1/utils/Compilation/JsImporter.ts b/src/v1/utils/Compilation/JsImporter.ts index 7a950206..d40a8d82 100644 --- a/src/v1/utils/Compilation/JsImporter.ts +++ b/src/v1/utils/Compilation/JsImporter.ts @@ -46,6 +46,9 @@ export class JsImporter implements IYamlImporter { const ksyModel = YamlParser.parseIKsyFile(ksyContent, fn); Object.assign(this.ksyTypes, SchemaUtils.collectKsyTypes(ksyModel)); - return ksyModel; + + // we have to modify the schema (add typesByJsName for example) before sending into the compiler, so we need a copy + const compilerSchema = YamlParser.parseIKsyFile(ksyContent, fn); + return compilerSchema; } } \ No newline at end of file diff --git a/src/v1/utils/Compilation/SchemaUtils.ts b/src/v1/utils/Compilation/SchemaUtils.ts index d8ce0f7a..8f858896 100644 --- a/src/v1/utils/Compilation/SchemaUtils.ts +++ b/src/v1/utils/Compilation/SchemaUtils.ts @@ -27,14 +27,11 @@ export class SchemaUtils { } static collectKsyTypes(schema: KsySchema.IKsyFile): IKsyTypes { - // Function was modifying input and the reason was: - // we have to modify the schema (add typesByJsName for example) before sending into the compiler, so we need a copy - const schemaTemp = {...schema}; var types: IKsyTypes = {}; - SchemaUtils.collectTypes(types, schemaTemp); + SchemaUtils.collectTypes(types, schema); - var typeName = SchemaUtils.ksyNameToJsName(schemaTemp.meta.id, false); - types[typeName] = schemaTemp; + var typeName = SchemaUtils.ksyNameToJsName(schema.meta.id, false); + types[typeName] = schema; return types; } diff --git a/src/v1/utils/LocalStorageApi.ts b/src/v1/utils/LocalStorageApi.ts index 1ec3cc7e..a79ccb55 100644 --- a/src/v1/utils/LocalStorageApi.ts +++ b/src/v1/utils/LocalStorageApi.ts @@ -29,7 +29,10 @@ export class LocalStorageApi { } public static storeIdeSettings = (store: IdeSettings): void => { - localStorage.setItem("ideSettings", JSON.stringify(store)); + const state: IdeSettings = { + eagerMode: store.eagerMode + }; + localStorage.setItem("ideSettings", JSON.stringify(state)); } public static getDoNotShowWelcomeFlag = (): boolean => {