Skip to content

Commit

Permalink
Do not return after fetch request and ensure interfaces are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Sep 7, 2023
1 parent d10242a commit e1f1324
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/renderer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,15 @@ 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;

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
Expand Down

0 comments on commit e1f1324

Please sign in to comment.