fix: restore positionBatchNodes/selectItems for multi-image and deduplicate getFileType

- Add back positionBatchNodes and selectItems calls in multi-image branch
- Extract duplicate getFileType into a module-level function
This commit is contained in:
bymyself
2026-03-12 08:06:30 -07:00
parent f04809d124
commit 93bb2d0d6f
2 changed files with 14 additions and 22 deletions

View File

@@ -4,6 +4,17 @@ import type { Page } from '@playwright/test'
import type { Position } from '../types'
function getFileType(fileName: string): string {
if (fileName.endsWith('.png')) return 'image/png'
if (fileName.endsWith('.svg')) return 'image/svg+xml'
if (fileName.endsWith('.webp')) return 'image/webp'
if (fileName.endsWith('.webm')) return 'video/webm'
if (fileName.endsWith('.json')) return 'application/json'
if (fileName.endsWith('.glb')) return 'model/gltf-binary'
if (fileName.endsWith('.avif')) return 'image/avif'
return 'application/octet-stream'
}
export class DragDropHelper {
constructor(
private readonly page: Page,
@@ -48,17 +59,6 @@ export class DragDropHelper {
const filePath = this.assetPath(fileName)
const buffer = readFileSync(filePath)
const getFileType = (fileName: string) => {
if (fileName.endsWith('.png')) return 'image/png'
if (fileName.endsWith('.svg')) return 'image/svg+xml'
if (fileName.endsWith('.webp')) return 'image/webp'
if (fileName.endsWith('.webm')) return 'video/webm'
if (fileName.endsWith('.json')) return 'application/json'
if (fileName.endsWith('.glb')) return 'model/gltf-binary'
if (fileName.endsWith('.avif')) return 'image/avif'
return 'application/octet-stream'
}
evaluateParams.fileName = fileName
evaluateParams.fileType = getFileType(fileName)
evaluateParams.buffer = [...new Uint8Array(buffer)]
@@ -169,17 +169,6 @@ export class DragDropHelper {
const filePath = this.assetPath(fileName)
const buffer = readFileSync(filePath)
const getFileType = (name: string) => {
if (name.endsWith('.png')) return 'image/png'
if (name.endsWith('.svg')) return 'image/svg+xml'
if (name.endsWith('.webp')) return 'image/webp'
if (name.endsWith('.webm')) return 'video/webm'
if (name.endsWith('.json')) return 'application/json'
if (name.endsWith('.glb')) return 'model/gltf-binary'
if (name.endsWith('.avif')) return 'image/avif'
return 'application/octet-stream'
}
return {
fileName,
fileType: getFileType(fileName),

View File

@@ -1732,6 +1732,9 @@ export class ComfyApp {
imageNodes.forEach((imageNode, index) => {
imageNode.connect(0, batchImagesNode, index)
})
this.positionBatchNodes(imageNodes, batchImagesNode)
this.canvas.selectItems([...imageNodes, batchImagesNode])
} else {
this.canvas.selectItems(imageNodes)
}