diff --git a/spx-gui/src/models/gen/animation-gen.ts b/spx-gui/src/models/gen/animation-gen.ts index 5029f8954..028185806 100644 --- a/spx-gui/src/models/gen/animation-gen.ts +++ b/spx-gui/src/models/gen/animation-gen.ts @@ -7,7 +7,8 @@ import { type AnimationSettings, enrichAnimationSettings, type TaskParamsExtractVideoFrames, - TaskType + TaskType, + TaskStatus } from '@/apis/aigc' import type { Project } from '../project' import { Sprite } from '../sprite' @@ -75,8 +76,11 @@ export class AnimationGen extends Disposable { return reactive(this) as this } + /** Get IDs for (completed) tasks. */ getTaskIds() { - return [this.generateVideoTask, this.extractFramesTask].map((t) => t.data?.id).filter((id) => id != null) + return [this.generateVideoTask, this.extractFramesTask] + .filter((t) => t.data?.status === TaskStatus.Completed) + .map((t) => t.data!.id) } get name() { diff --git a/spx-gui/src/models/gen/backdrop-gen.ts b/spx-gui/src/models/gen/backdrop-gen.ts index ddddaddf7..e4bdde06f 100644 --- a/spx-gui/src/models/gen/backdrop-gen.ts +++ b/spx-gui/src/models/gen/backdrop-gen.ts @@ -2,7 +2,7 @@ import { nanoid } from 'nanoid' import { reactive } from 'vue' import { Disposable } from '@/utils/disposable' import { ArtStyle, BackdropCategory, Perspective } from '@/apis/common' -import { adoptAsset, enrichBackdropSettings, TaskType, type BackdropSettings } from '@/apis/aigc' +import { adoptAsset, enrichBackdropSettings, TaskType, TaskStatus, type BackdropSettings } from '@/apis/aigc' import type { File } from '../common/file' import { createFileWithUniversalUrl } from '../common/cloud' import { validateBackdropName } from '../common/asset-name' @@ -104,7 +104,7 @@ export class BackdropGen extends Disposable { async recordAdoption() { const backdrop = this.result if (backdrop == null) throw new Error('result backdrop expected') - const taskIds = this.generateTask.data != null ? [this.generateTask.data.id] : [] + const taskIds = this.generateTask.data?.status === TaskStatus.Completed ? [this.generateTask.data.id] : [] const assetData = await backdrop2Asset(backdrop) const { name: displayName, description, ...extraSettings } = this.settings return adoptAsset({ diff --git a/spx-gui/src/models/gen/costume-gen.ts b/spx-gui/src/models/gen/costume-gen.ts index f4d82b267..a606664e9 100644 --- a/spx-gui/src/models/gen/costume-gen.ts +++ b/spx-gui/src/models/gen/costume-gen.ts @@ -3,7 +3,7 @@ import { reactive } from 'vue' import type { Prettify } from '@/utils/types' import { Disposable } from '@/utils/disposable' import { ArtStyle, Perspective } from '@/apis/common' -import { enrichCostumeSettings, Facing, TaskType, type CostumeSettings } from '@/apis/aigc' +import { enrichCostumeSettings, Facing, TaskType, TaskStatus, type CostumeSettings } from '@/apis/aigc' import type { File } from '../common/file' import { ensureValidCostumeName, validateCostumeName } from '../common/asset-name' import { createFileWithUniversalUrl, saveFile } from '../common/cloud' @@ -61,8 +61,9 @@ export class CostumeGen extends Disposable { return reactive(this) as this } + /** Get IDs for (completed) tasks. */ getTaskIds() { - if (this.generateTask.data == null) return [] + if (this.generateTask.data?.status !== TaskStatus.Completed) return [] return [this.generateTask.data.id] } diff --git a/spx-gui/src/models/gen/sprite-gen.ts b/spx-gui/src/models/gen/sprite-gen.ts index 135847982..be298035d 100644 --- a/spx-gui/src/models/gen/sprite-gen.ts +++ b/spx-gui/src/models/gen/sprite-gen.ts @@ -10,6 +10,7 @@ import { type CostumeSettings, Facing, TaskType, + TaskStatus, adoptAsset } from '@/apis/aigc' import { Project } from '../project' @@ -357,7 +358,7 @@ export class SpriteGen extends Disposable { const sprite = this.result if (sprite == null) throw new Error('result sprite expected') const taskIds = [ - this.genImagesTask.data?.id, + this.genImagesTask.data?.status === TaskStatus.Completed ? this.genImagesTask.data.id : null, ...this.costumes.flatMap((c) => c.getTaskIds()), ...this.animations.flatMap((a) => a.getTaskIds()) ].filter((id) => id != null)