Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions spx-gui/src/models/gen/animation-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions spx-gui/src/models/gen/backdrop-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions spx-gui/src/models/gen/costume-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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]
}

Expand Down
3 changes: 2 additions & 1 deletion spx-gui/src/models/gen/sprite-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type CostumeSettings,
Facing,
TaskType,
TaskStatus,
adoptAsset
} from '@/apis/aigc'
import { Project } from '../project'
Expand Down Expand Up @@ -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)
Expand Down