mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 08:00:05 +00:00
Move error handling out of api.ts to workflows.ts (#600)
This commit is contained in:
@@ -541,11 +541,7 @@ class ComfyApi extends EventTarget {
|
||||
const resp = await this.fetchApi(`/userdata/${encodeURIComponent(file)}`, {
|
||||
method: 'DELETE'
|
||||
})
|
||||
if (resp.status !== 204) {
|
||||
throw new Error(
|
||||
`Error removing user data file '${file}': ${resp.status} ${resp.statusText}`
|
||||
)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -399,19 +399,21 @@ export class ComfyWorkflow {
|
||||
async delete() {
|
||||
// TODO: fix delete of current workflow - should mark workflow as unsaved and when saving use old name by default
|
||||
|
||||
try {
|
||||
if (this.isFavorite) {
|
||||
await this.favorite(false)
|
||||
}
|
||||
await api.deleteUserData('workflows/' + this.path)
|
||||
this.unsaved = true
|
||||
this.#path = null
|
||||
this.#pathParts = null
|
||||
this.manager.workflows.splice(this.manager.workflows.indexOf(this), 1)
|
||||
this.manager.dispatchEvent(new CustomEvent('delete', { detail: this }))
|
||||
} catch (error) {
|
||||
alert(`Error deleting workflow: ${error.message || error}`)
|
||||
if (this.isFavorite) {
|
||||
await this.favorite(false)
|
||||
}
|
||||
const resp = await api.deleteUserData('workflows/' + this.path)
|
||||
if (resp.status !== 204) {
|
||||
alert(
|
||||
`Error removing user data file '${this.path}': ${resp.status} ${resp.statusText}`
|
||||
)
|
||||
}
|
||||
|
||||
this.unsaved = true
|
||||
this.#path = null
|
||||
this.#pathParts = null
|
||||
this.manager.workflows.splice(this.manager.workflows.indexOf(this), 1)
|
||||
this.manager.dispatchEvent(new CustomEvent('delete', { detail: this }))
|
||||
}
|
||||
|
||||
track() {
|
||||
|
||||
Reference in New Issue
Block a user