mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 16:40:05 +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)
|
||||
|
||||
// Verify API call includes correct category
|
||||
// Verify API call includes correct category (comma is URL-encoded by URLSearchParams)
|
||||
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[]>(() => {
|
||||
return assets.value.map((asset) => ({
|
||||
return (assets.value ?? []).map((asset) => ({
|
||||
id: asset.id,
|
||||
name:
|
||||
(asset.user_metadata?.filename as string | undefined) ?? asset.name,
|
||||
@@ -65,7 +65,8 @@ export function useAssetWidgetData(
|
||||
return
|
||||
}
|
||||
|
||||
const hasData = assetsStore.getAssets(currentNodeType).length > 0
|
||||
const existingAssets = assetsStore.getAssets(currentNodeType) ?? []
|
||||
const hasData = existingAssets.length > 0
|
||||
|
||||
if (!hasData) {
|
||||
await assetsStore.updateModelsForNodeType(currentNodeType)
|
||||
|
||||
Reference in New Issue
Block a user