Updated: ‘Reload Custom Script’ button now uses latest object_Info from Comfy API

pull/369/head
Abdullah Alfaraj 2023-11-29 05:28:10 +03:00
parent ddde1b3ae8
commit 2ebd9e4b0e
2 changed files with 13 additions and 3 deletions

View File

@ -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${

View File

@ -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