mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-25 08:49:36 +00:00
refactor: simplify PackInstallButton isInstalling state management
- Remove isInstalling prop from PackInstallButton component - Use internal computed property with comfyManagerStore.isPackInstalling() - Remove redundant isInstalling computations from parent components - Fix test mocks for useConflictDetection and es-toolkit/compat - Clean up unused imports and inject dependencies This centralizes the installation state management in the store, reducing code duplication and complexity across components. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,6 @@ type NodePack = components['schemas']['Node']
|
||||
const {
|
||||
nodePacks,
|
||||
isLoading = false,
|
||||
isInstalling = false,
|
||||
label = 'Install',
|
||||
size = 'sm',
|
||||
hasConflict,
|
||||
@@ -55,7 +54,6 @@ const {
|
||||
} = defineProps<{
|
||||
nodePacks: NodePack[]
|
||||
isLoading?: boolean
|
||||
isInstalling?: boolean
|
||||
label?: string
|
||||
size?: ButtonSize
|
||||
hasConflict?: boolean
|
||||
@@ -65,6 +63,12 @@ const {
|
||||
const managerStore = useComfyManagerStore()
|
||||
const { showNodeConflictDialog } = useDialogService()
|
||||
|
||||
// Check if any of the packs are currently being installed
|
||||
const isInstalling = computed(() => {
|
||||
if (!nodePacks?.length) return false
|
||||
return nodePacks.some((pack) => managerStore.isPackInstalling(pack.id))
|
||||
})
|
||||
|
||||
const createPayload = (installItem: NodePack) => {
|
||||
if (!installItem.id) {
|
||||
throw new Error('Node ID is required for installation')
|
||||
@@ -107,14 +111,12 @@ const installAllPacks = async () => {
|
||||
buttonText: t('manager.conflicts.installAnyway'),
|
||||
onButtonClick: async () => {
|
||||
// Proceed with installation
|
||||
// isInstalling.value = true
|
||||
await performInstallation(nodePacks)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
// No conflicts or conflicts acknowledged - proceed with installation
|
||||
// isInstalling.value = true
|
||||
await performInstallation(nodePacks)
|
||||
}
|
||||
|
||||
@@ -124,7 +126,7 @@ const performInstallation = async (packs: NodePack[]) => {
|
||||
}
|
||||
|
||||
const computedLabel = computed(() =>
|
||||
isInstalling
|
||||
isInstalling.value
|
||||
? t('g.installing')
|
||||
: label ??
|
||||
(nodePacks.length > 1 ? t('manager.installSelected') : t('g.install'))
|
||||
|
||||
Reference in New Issue
Block a user