fix
This commit is contained in:
@@ -420,13 +420,22 @@ const reusePrompt = (gen) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const reuseAsset = (gen) => {
|
const reuseAsset = (gen) => {
|
||||||
if (gen.input_assets && Array.isArray(gen.input_assets)) {
|
const assetIds = gen.assets_list || gen.input_assets || []
|
||||||
selectedAssets.value = gen.input_assets.map(id => ({
|
|
||||||
|
if (assetIds && assetIds.length > 0) {
|
||||||
|
selectedAssets.value = assetIds.map(id => {
|
||||||
|
// Check if we have it in characterAssets
|
||||||
|
const existing = characterAssets.value.find(a => a.id === id)
|
||||||
|
if (existing) return existing
|
||||||
|
|
||||||
|
return {
|
||||||
id,
|
id,
|
||||||
url: `/assets/${id}`
|
url: `/assets/${id}`,
|
||||||
}))
|
name: 'Asset ' + id.substring(0, 6)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
console.warn("Input assets not found in history object:", gen)
|
console.warn("No linked/input assets found in history object:", gen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -383,17 +383,26 @@ const reuseAsset = (gen) => {
|
|||||||
// Attempt to access input assets if available, otherwise warn or try to fetch.
|
// Attempt to access input assets if available, otherwise warn or try to fetch.
|
||||||
// NOTE: In many systems, the input assets are stored in metadata.
|
// NOTE: In many systems, the input assets are stored in metadata.
|
||||||
|
|
||||||
if (gen.input_assets && Array.isArray(gen.input_assets)) {
|
const reuseAsset = (gen) => {
|
||||||
selectedAssets.value = gen.input_assets.map(id => ({
|
// Try to find input assets field from history object
|
||||||
|
// We check linked_assets or input_assets, and fallback to empty array if not found
|
||||||
|
const assetIds = gen.linked_assets || gen.input_assets || []
|
||||||
|
|
||||||
|
if (assetIds && assetIds.length > 0) {
|
||||||
|
selectedAssets.value = assetIds.map(id => {
|
||||||
|
// Check if we already have the full asset object loaded to get the name/type
|
||||||
|
const existing = allAssets.value.find(a => a.id === id)
|
||||||
|
if (existing) return existing
|
||||||
|
|
||||||
|
// Fallback: Construct object to display thumbnail
|
||||||
|
return {
|
||||||
id,
|
id,
|
||||||
url: `/assets/${id}` // Construct URL
|
url: `/assets/${id}`,
|
||||||
}))
|
name: 'Asset ' + id.substring(0, 6) // Placeholder name
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Fallback or todo: Backend might need to provide `input_assets` in history.
|
console.warn("No linked/input assets found in history object:", gen)
|
||||||
// For now, let's toast or log.
|
|
||||||
console.warn("Input assets not found in history object:", gen)
|
|
||||||
// If the user meant the generated asset (the prompt is slightly ambiguous "associated asset" vs "result"),
|
|
||||||
// but point 3 is explicitly "use result".
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user