From 7a59c23d20331a09710fc20505d510f3a4e32965 Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Thu, 13 Oct 2022 18:36:35 +0200 Subject: [PATCH] Fix Configuration.cs requiring APIConfiguration (which do not) + Fix menuActions --- .../SVGLDLibs/Models/Configuration.cs | 2 +- src/Components/App/Actions/MenuActions.ts | 21 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/csharp/SVGLDLibs/SVGLDLibs/Models/Configuration.cs b/csharp/SVGLDLibs/SVGLDLibs/Models/Configuration.cs index 6ac44eb..8c156e5 100644 --- a/csharp/SVGLDLibs/SVGLDLibs/Models/Configuration.cs +++ b/csharp/SVGLDLibs/SVGLDLibs/Models/Configuration.cs @@ -32,7 +32,7 @@ namespace SVGLDLibs.Models [DataMember(EmitDefaultValue = false, IsRequired = true)] public AvailableContainerModel MainContainer { get; set; } - [DataMember(EmitDefaultValue = false, IsRequired = true)] + [DataMember(EmitDefaultValue = false)] public APIConfiguration APIConfiguration { get; set; } } } \ No newline at end of file diff --git a/src/Components/App/Actions/MenuActions.ts b/src/Components/App/Actions/MenuActions.ts index b81561f..3d72cd7 100644 --- a/src/Components/App/Actions/MenuActions.ts +++ b/src/Components/App/Actions/MenuActions.ts @@ -10,7 +10,14 @@ export function NewEditor( setEditorState: (newState: IEditorState) => void, enableLoaded: () => void ): void { - UseLoadOnBoot(enableLoaded, editorState); + if (DISABLE_API) { + enableLoaded(); + } + + if (editorState.configuration.APIConfiguration !== undefined) { + enableLoaded(); + return; + } // Fetch the configuration from the API FetchConfiguration() @@ -26,18 +33,6 @@ export function NewEditor( }); } -function UseLoadOnBoot(enableLoaded: () => void, editorState: IEditorState): void { - useEffect(() => { - if (DISABLE_API) { - enableLoaded(); - return; - } - if (editorState.configuration !== undefined) { - enableLoaded(); - } - }, []); -} - export function LoadEditor( files: FileList | null, setEditorState: Dispatch>,