fix: add defensive checks for undefined assets in useAssetWidgetData

This commit is contained in:
Alexander Brown
2026-01-17 19:07:44 -08:00
parent f5b422d493
commit 71c36991d3
2 changed files with 5 additions and 4 deletions

View File

@@ -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'
)
})

View File

@@ -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)