mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Add finally handler for rename tree node action (#1403)
* Add finally handler for rename tree node action * nit
This commit is contained in:
@@ -80,9 +80,11 @@ const errorHandling = useErrorHandling()
|
||||
const handleRename = errorHandling.wrapWithErrorHandlingAsync(
|
||||
async (newName: string) => {
|
||||
await props.node.handleRename(props.node, newName)
|
||||
renameEditingNode.value = null
|
||||
},
|
||||
props.node.handleError
|
||||
props.node.handleError,
|
||||
() => {
|
||||
renameEditingNode.value = null
|
||||
}
|
||||
)
|
||||
const container = ref<HTMLElement | null>(null)
|
||||
const canDrop = ref(false)
|
||||
|
||||
@@ -177,12 +177,12 @@ const renderTreeNode = (node: TreeNode): TreeExplorerNode<ComfyWorkflow> => {
|
||||
const actions = node.leaf
|
||||
? {
|
||||
handleClick,
|
||||
handleRename: (
|
||||
handleRename: async (
|
||||
node: TreeExplorerNode<ComfyWorkflow>,
|
||||
newName: string
|
||||
) => {
|
||||
const workflow = node.data
|
||||
workflow.rename(newName)
|
||||
await workflow.rename(newName)
|
||||
},
|
||||
handleDelete: workflow.isTemporary
|
||||
? undefined
|
||||
|
||||
@@ -39,7 +39,6 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useTreeExpansion } from '@/hooks/treeHooks'
|
||||
import { app } from '@/scripts/app'
|
||||
import { findNodeByKey } from '@/utils/treeUtil'
|
||||
import { useErrorHandling } from '@/hooks/errorHooks'
|
||||
|
||||
const props = defineProps<{
|
||||
filteredNodeDefs: ComfyNodeDefImpl[]
|
||||
@@ -212,13 +211,11 @@ defineExpose({
|
||||
addNewBookmarkFolder
|
||||
})
|
||||
|
||||
const handleRename = useErrorHandling().wrapWithErrorHandling(
|
||||
(node: TreeNode, newName: string) => {
|
||||
if (node.data && node.data.isDummyFolder) {
|
||||
nodeBookmarkStore.renameBookmarkFolder(node.data, newName)
|
||||
}
|
||||
const handleRename = (node: TreeNode, newName: string) => {
|
||||
if (node.data && node.data.isDummyFolder) {
|
||||
nodeBookmarkStore.renameBookmarkFolder(node.data, newName)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const showCustomizationDialog = ref(false)
|
||||
const initialIcon = ref(nodeBookmarkStore.defaultBookmarkIcon)
|
||||
|
||||
@@ -15,25 +15,34 @@ export function useErrorHandling() {
|
||||
}
|
||||
|
||||
const wrapWithErrorHandling =
|
||||
(action: (...args: any[]) => any, errorHandler?: (error: any) => void) =>
|
||||
(
|
||||
action: (...args: any[]) => any,
|
||||
errorHandler?: (error: any) => void,
|
||||
finallyHandler?: () => void
|
||||
) =>
|
||||
(...args: any[]) => {
|
||||
try {
|
||||
return action(...args)
|
||||
} catch (e) {
|
||||
;(errorHandler ?? toastErrorHandler)(e)
|
||||
} finally {
|
||||
finallyHandler?.()
|
||||
}
|
||||
}
|
||||
|
||||
const wrapWithErrorHandlingAsync =
|
||||
(
|
||||
action: ((...args: any[]) => Promise<any>) | ((...args: any[]) => any),
|
||||
errorHandler?: (error: any) => void
|
||||
errorHandler?: (error: any) => void,
|
||||
finallyHandler?: () => void
|
||||
) =>
|
||||
async (...args: any[]) => {
|
||||
try {
|
||||
return await action(...args)
|
||||
} catch (e) {
|
||||
;(errorHandler ?? toastErrorHandler)(e)
|
||||
} finally {
|
||||
finallyHandler?.()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user