mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: clear missing media errors when widget value changes on node
Add removeMissingMediaByWidget to missingMediaStore and call it from clearWidgetRelatedErrors, matching the existing missing model pattern. When a user changes a media widget value directly on a node, the corresponding missing media error is removed from the error tab.
This commit is contained in:
@@ -102,6 +102,38 @@ describe('useMissingMediaStore', () => {
|
||||
expect(store.hasMissingMediaOnNode('99')).toBe(false)
|
||||
})
|
||||
|
||||
it('removeMissingMediaByWidget removes matching node+widget entry', () => {
|
||||
const store = useMissingMediaStore()
|
||||
store.setMissingMedia([
|
||||
makeCandidate('1', 'photo.png'),
|
||||
makeCandidate('2', 'clip.mp4', 'video')
|
||||
])
|
||||
|
||||
store.removeMissingMediaByWidget('1', 'image')
|
||||
|
||||
expect(store.missingMediaCandidates).toHaveLength(1)
|
||||
expect(store.missingMediaCandidates![0].name).toBe('clip.mp4')
|
||||
})
|
||||
|
||||
it('removeMissingMediaByWidget nulls candidates when last entry removed', () => {
|
||||
const store = useMissingMediaStore()
|
||||
store.setMissingMedia([makeCandidate('1', 'photo.png')])
|
||||
|
||||
store.removeMissingMediaByWidget('1', 'image')
|
||||
|
||||
expect(store.missingMediaCandidates).toBeNull()
|
||||
expect(store.hasMissingMedia).toBe(false)
|
||||
})
|
||||
|
||||
it('removeMissingMediaByWidget ignores non-matching entries', () => {
|
||||
const store = useMissingMediaStore()
|
||||
store.setMissingMedia([makeCandidate('1', 'photo.png')])
|
||||
|
||||
store.removeMissingMediaByWidget('99', 'image')
|
||||
|
||||
expect(store.missingMediaCandidates).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('createVerificationAbortController aborts previous controller', () => {
|
||||
const store = useMissingMediaStore()
|
||||
const first = store.createVerificationAbortController()
|
||||
|
||||
@@ -97,6 +97,15 @@ export const useMissingMediaStore = defineStore('missingMedia', () => {
|
||||
missingMediaCandidates.value = null
|
||||
}
|
||||
|
||||
function removeMissingMediaByWidget(nodeId: string, widgetName: string) {
|
||||
if (!missingMediaCandidates.value) return
|
||||
missingMediaCandidates.value = missingMediaCandidates.value.filter(
|
||||
(m) => !(String(m.nodeId) === nodeId && m.widgetName === widgetName)
|
||||
)
|
||||
if (!missingMediaCandidates.value.length)
|
||||
missingMediaCandidates.value = null
|
||||
}
|
||||
|
||||
function clearMissingMedia() {
|
||||
_verificationAbortController?.abort()
|
||||
_verificationAbortController = null
|
||||
@@ -116,6 +125,7 @@ export const useMissingMediaStore = defineStore('missingMedia', () => {
|
||||
|
||||
setMissingMedia,
|
||||
removeMissingMediaByName,
|
||||
removeMissingMediaByWidget,
|
||||
clearMissingMedia,
|
||||
createVerificationAbortController,
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => {
|
||||
options
|
||||
)
|
||||
missingModelStore.removeMissingModelByWidget(executionId, widgetName)
|
||||
missingMediaStore.removeMissingMediaByWidget(executionId, widgetName)
|
||||
}
|
||||
|
||||
/** Set missing models and open the error overlay if the Errors tab is enabled. */
|
||||
|
||||
Reference in New Issue
Block a user