mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 22:09:55 +00:00
Fix race when creating loader node to handle pasted media (#2799)
This commit is contained in:
@@ -20,6 +20,11 @@ interface NodePreviewOptions<T extends MediaElement> {
|
||||
onFailedLoading?: () => void
|
||||
}
|
||||
|
||||
interface ShowPreviewOptions {
|
||||
/** If true, blocks new loading operations until the current operation is complete. */
|
||||
block?: boolean
|
||||
}
|
||||
|
||||
const createContainer = () => {
|
||||
const container = document.createElement('div')
|
||||
container.classList.add('comfy-img-preview')
|
||||
@@ -58,13 +63,13 @@ export const useNodePreview = <T extends MediaElement>(
|
||||
/**
|
||||
* Displays media element(s) on the node.
|
||||
*/
|
||||
function showPreview() {
|
||||
function showPreview(options: ShowPreviewOptions = {}) {
|
||||
if (node.isLoading) return
|
||||
|
||||
const outputUrls = nodeOutputStore.getNodeImageUrls(node)
|
||||
if (!outputUrls?.length) return
|
||||
|
||||
node.isLoading = true
|
||||
if (options?.block) node.isLoading = true
|
||||
|
||||
loadElements(outputUrls)
|
||||
.then((elements) => {
|
||||
|
||||
@@ -106,7 +106,7 @@ export const useImageUploadWidget = () => {
|
||||
// No change callbacks seem to be fired on initial setting of the value
|
||||
requestAnimationFrame(() => {
|
||||
nodeOutputStore.setNodeOutputs(node, fileComboWidget.value)
|
||||
showPreview()
|
||||
showPreview({ block: false })
|
||||
})
|
||||
|
||||
return { widget: uploadWidget }
|
||||
|
||||
Reference in New Issue
Block a user