From e1f13248d790b8cfef0825e3eb7d74adb944a042 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn <46533749+GarrettMFlynn@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:36:16 -0700 Subject: [PATCH] Do not return after fetch request and ensure interfaces are defined --- src/renderer/src/index.ts | 7 ++----- .../src/stories/pages/guided-mode/data/GuidedStructure.js | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/index.ts b/src/renderer/src/index.ts index 54d841024..c13b6f258 100644 --- a/src/renderer/src/index.ts +++ b/src/renderer/src/index.ts @@ -101,10 +101,7 @@ const serverIsLiveStartup = async () => { }; // Preload Flask imports for faster on-demand operations -const preloadFlaskImports = async () => { - const result = await fetch(`${baseUrl}/startup/preload-imports`).then(res => res.json()).catch(e => e) - return result -}; +const preloadFlaskImports = async () => await fetch(`${baseUrl}/startup/preload-imports`).then(res => res.json()).catch(e => e) let openPythonStatusNotyf: undefined | any; @@ -112,7 +109,7 @@ async function pythonServerOpened() { // Confirm requests are actually received by the server const isLive = await serverIsLiveStartup() - if (isLive) return preloadFlaskImports() // initiate preload of Flask imports + if (isLive) await preloadFlaskImports() // initiate preload of Flask imports if (!isLive) return pythonServerClosed() // Update server status and throw a notification diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js index 93938a8ca..b4c24266d 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js @@ -75,9 +75,9 @@ export class GuidedStructurePage extends Page { }; async updated() { - const selected = this.info.globalState.interfaces; + const { interfaces = {} } = this.info.globalState; - if (Object.keys(selected).length > 0) this.list.emptyMessage = "Loading valid interfaces..."; + if (Object.keys(interfaces).length > 0) this.list.emptyMessage = "Loading valid interfaces..."; this.search.options = await fetch(`${baseUrl}/neuroconv`) .then((res) => res.json()) @@ -93,7 +93,7 @@ export class GuidedStructurePage extends Page { ) .catch((e) => console.error(e)); - for (const [key, name] of Object.entries(selected || {})) { + for (const [key, name] of Object.entries(interfaces)) { let found = this.search.options?.find((o) => o.value === name); // If not found, spoof based on the key and names provided previously