From 9c6cca29448a14b71d9b4d8c8f11fadfc0fd99fc Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Tue, 20 Aug 2024 14:07:32 -0700 Subject: [PATCH] Revert "reflow machines from k/v" (#3575) This reverts commit f77b312ecb7882617bdc30c727523374e6e2bb41. --- src/lib/machineManager.ts | 8 +++++--- src/preload.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/machineManager.ts b/src/lib/machineManager.ts index b5b5198eb..da0fcca80 100644 --- a/src/lib/machineManager.ts +++ b/src/lib/machineManager.ts @@ -1,11 +1,13 @@ import { isDesktop } from './isDesktop' import { components } from './machine-api' -export type MachinesListing = Array +export type MachinesListing = { + [key: string]: components['schemas']['Machine'] +} export class MachineManager { private _isDesktop: boolean = isDesktop() - private _machines: MachinesListing = [] + private _machines: MachinesListing = {} private _machineApiIp: string | null = null private _currentMachine: components['schemas']['Machine'] | null = null @@ -42,7 +44,7 @@ export class MachineManager { } machineCount(): number { - return this._machines.length + return Object.keys(this._machines).length } get machineApiIp(): string | null { diff --git a/src/preload.ts b/src/preload.ts index fa1983a0a..9683aa543 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -52,7 +52,7 @@ const kittycad = (access: string, args: any) => // bite our butts. const listMachines = async (): Promise => { const machineApi = await ipcRenderer.invoke('find_machine_api') - if (!machineApi) return [] + if (!machineApi) return {} return fetch(`http://${machineApi}/machines`).then((resp) => resp.json()) }