diff --git a/src/components/common/TreeExplorerTreeNode.vue b/src/components/common/TreeExplorerTreeNode.vue index 2c8ee927..d2c4f48e 100644 --- a/src/components/common/TreeExplorerTreeNode.vue +++ b/src/components/common/TreeExplorerTreeNode.vue @@ -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(null) const canDrop = ref(false) diff --git a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue index 245b882e..5c138868 100644 --- a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue +++ b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue @@ -177,12 +177,12 @@ const renderTreeNode = (node: TreeNode): TreeExplorerNode => { const actions = node.leaf ? { handleClick, - handleRename: ( + handleRename: async ( node: TreeExplorerNode, newName: string ) => { const workflow = node.data - workflow.rename(newName) + await workflow.rename(newName) }, handleDelete: workflow.isTemporary ? undefined diff --git a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue index 5e1c8753..89fb1bcc 100644 --- a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue +++ b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue @@ -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) diff --git a/src/hooks/errorHooks.ts b/src/hooks/errorHooks.ts index 9d5762ed..50b2352c 100644 --- a/src/hooks/errorHooks.ts +++ b/src/hooks/errorHooks.ts @@ -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) | ((...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?.() } }