|
|
|
@ -151,36 +151,6 @@ function hasMusicCreationAudio(asset: Record<string, unknown>): boolean { |
|
|
|
return candidates.some((candidate) => String(candidate ?? "").trim().length > 0); |
|
|
|
} |
|
|
|
|
|
|
|
function isVideoOrAudioCandidate(candidate: Record<string, unknown>): boolean { |
|
|
|
const type = String(candidate.type ?? candidate.mediaType ?? candidate.mimeType ?? "").toLowerCase(); |
|
|
|
const url = String(candidate.url ?? "").toLowerCase(); |
|
|
|
return type.includes("video") || type.includes("audio") || /\.(mp4|mov|webm|mp3|wav|m4a)(\?.*)?$/.test(url); |
|
|
|
} |
|
|
|
|
|
|
|
function pickUrlCandidate(...candidates: unknown[]): string { |
|
|
|
for (const candidate of candidates) { |
|
|
|
if (Array.isArray(candidate)) { |
|
|
|
const nested = pickUrlCandidate(...candidate); |
|
|
|
if (nested) return nested; |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (candidate && typeof candidate === "object") { |
|
|
|
const row = candidate as Record<string, unknown>; |
|
|
|
const nested = pickUrlCandidate(row.thumbUrl, row.coverUrl, row.cover, row.imageUrl, row.image, isVideoOrAudioCandidate(row) ? "" : row.url); |
|
|
|
if (nested) return nested; |
|
|
|
continue; |
|
|
|
} |
|
|
|
const value = String(candidate ?? "").trim(); |
|
|
|
if (value) return value; |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
function getPendingCreationImage(task: Record<string, unknown>): string { |
|
|
|
const assetDraft = task.assetDraft && typeof task.assetDraft === "object" ? (task.assetDraft as Record<string, unknown>) : null; |
|
|
|
return pickUrlCandidate(assetDraft?.coverUrl, assetDraft?.cover, assetDraft?.thumbUrl, assetDraft?.imageUrl, assetDraft?.image, task.coverUrl, task.cover, task.thumbUrl, task.imageUrl, task.image, task.images, task.referenceSubjectList, task.voiceLibrary); |
|
|
|
} |
|
|
|
|
|
|
|
function flattenMusicCreationAssetIds(assetList: any[]): string[] { |
|
|
|
const ids: string[] = []; |
|
|
|
for (const task of assetList) { |
|
|
|
@ -941,14 +911,12 @@ export default function MyCreationsPanel({ tabIdPrefix, setToolbarExtra }: MyCre |
|
|
|
{taskList.map((task: any, taskIdx: number) => { |
|
|
|
if (task.status == 0 || task.status == 1) { |
|
|
|
const taskId = getTaskRowId(task) || `idx-${taskIdx}`; |
|
|
|
const pendingImageSrc = getPendingCreationImage(task); |
|
|
|
return Array.from({ length: Number(task.batchSize || 0) }, (_, slotIdx) => ( |
|
|
|
<AssetGalleryTile |
|
|
|
key={`pending-${taskId}-${slotIdx}`} |
|
|
|
kind="pending" |
|
|
|
rowKey={`pending-${taskId}-${slotIdx}`} |
|
|
|
pendingLabel={task.status == 0 ? t("pages.create.panels.myCreations.queued") : t("pages.create.panels.myCreations.generating")} |
|
|
|
pendingImageSrc={pendingImageSrc} |
|
|
|
/> |
|
|
|
)); |
|
|
|
} |
|
|
|
|