From 2ebd9e4b0efe3439497581a3dcac7b08df6f0cef Mon Sep 17 00:00:00 2001 From: Abdullah Alfaraj <7842232+AbdullahAlfaraj@users.noreply.github.com> Date: Wed, 29 Nov 2023 05:28:10 +0300 Subject: [PATCH] =?UTF-8?q?Updated:=20=E2=80=98Reload=20Custom=20Script?= =?UTF-8?q?=E2=80=99=20button=20now=20uses=20latest=20object=5FInfo=20from?= =?UTF-8?q?=20Comfy=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescripts/comfyui/comfyapi.ts | 14 +++++++++++--- typescripts/comfyui/comfyui.tsx | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/typescripts/comfyui/comfyapi.ts b/typescripts/comfyui/comfyapi.ts index 9a1dac52..f8114807 100644 --- a/typescripts/comfyui/comfyapi.ts +++ b/typescripts/comfyui/comfyapi.ts @@ -28,7 +28,7 @@ class ComfyAPI { } async init() { try { - this.object_info = await this.getObjectInfo(this.comfy_url) + this.object_info = await this.initializeObjectInfo(this.comfy_url) this.status = true return this.object_info } catch (e) { @@ -41,7 +41,7 @@ class ComfyAPI { this.comfy_url = comfy_url } async refresh() { - this.object_info = await this.getObjectInfo(this.comfy_url) + this.object_info = await this.initializeObjectInfo(this.comfy_url) } async queue() { const res = await requestGet(`${this.comfy_url}/queue`) @@ -82,7 +82,7 @@ class ComfyAPI { return Buffer.from(ab).toString('base64') } - async getObjectInfo(comfy_url: string) { + async initializeObjectInfo(comfy_url: string) { try { const full_url = `${comfy_url}/object_info` const object_info = await requestGet(full_url) @@ -94,6 +94,14 @@ class ComfyAPI { throw e } } + getObjectInfo() { + try { + return this.object_info + } catch (e) { + console.error(e) + throw e + } + } getReadableError(result: ComfyResult): string { const parseError = (error: any) => `Error: ${error.message}\n${ diff --git a/typescripts/comfyui/comfyui.tsx b/typescripts/comfyui/comfyui.tsx index 34ae57d7..0ba6f733 100644 --- a/typescripts/comfyui/comfyui.tsx +++ b/typescripts/comfyui/comfyui.tsx @@ -1416,6 +1416,8 @@ class ComfyWorkflowComponent extends React.Component<{}, { value?: number }> { className="btnSquare refreshButton btnResetSettings" title="reload the current workflow" onClick={async () => { + store.data.object_info = + comfyapi.comfy_api.getObjectInfo() loadWorkflow2( store.data.workflows2[ store.data.selected_workflow_name