mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
fix: add defensive checks for undefined assets in useAssetWidgetData
This commit is contained in:
@@ -231,9 +231,9 @@ describe('assetService', () => {
|
|||||||
)
|
)
|
||||||
expect(result).toEqual(testAssets)
|
expect(result).toEqual(testAssets)
|
||||||
|
|
||||||
// Verify API call includes correct category
|
// Verify API call includes correct category (comma is URL-encoded by URLSearchParams)
|
||||||
expect(api.fetchApi).toHaveBeenCalledWith(
|
expect(api.fetchApi).toHaveBeenCalledWith(
|
||||||
'/assets?include_tags=models,checkpoints&limit=500'
|
'/assets?include_tags=models%2Ccheckpoints&limit=500'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export function useAssetWidgetData(
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dropdownItems = computed<DropdownItem[]>(() => {
|
const dropdownItems = computed<DropdownItem[]>(() => {
|
||||||
return assets.value.map((asset) => ({
|
return (assets.value ?? []).map((asset) => ({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
name:
|
name:
|
||||||
(asset.user_metadata?.filename as string | undefined) ?? asset.name,
|
(asset.user_metadata?.filename as string | undefined) ?? asset.name,
|
||||||
@@ -65,7 +65,8 @@ export function useAssetWidgetData(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasData = assetsStore.getAssets(currentNodeType).length > 0
|
const existingAssets = assetsStore.getAssets(currentNodeType) ?? []
|
||||||
|
const hasData = existingAssets.length > 0
|
||||||
|
|
||||||
if (!hasData) {
|
if (!hasData) {
|
||||||
await assetsStore.updateModelsForNodeType(currentNodeType)
|
await assetsStore.updateModelsForNodeType(currentNodeType)
|
||||||
|
|||||||
Reference in New Issue
Block a user