diff --git a/graphql/documents/mutations/scene.graphql b/graphql/documents/mutations/scene.graphql index 80c38d109..0915b48cd 100644 --- a/graphql/documents/mutations/scene.graphql +++ b/graphql/documents/mutations/scene.graphql @@ -80,6 +80,10 @@ mutation SceneDestroy($id: ID!, $delete_file: Boolean, $delete_generated : Boole sceneDestroy(input: {id: $id, delete_file: $delete_file, delete_generated: $delete_generated}) } +mutation ScenesDestroy($ids: [ID!]!, $delete_file: Boolean, $delete_generated : Boolean) { + scenesDestroy(input: {ids: $ids, delete_file: $delete_file, delete_generated: $delete_generated}) +} + mutation SceneGenerateScreenshot($id: ID!, $at: Float) { sceneGenerateScreenshot(id: $id, at: $at) } diff --git a/graphql/schema/schema.graphql b/graphql/schema/schema.graphql index e72adadf7..9624a41a6 100644 --- a/graphql/schema/schema.graphql +++ b/graphql/schema/schema.graphql @@ -105,6 +105,7 @@ type Mutation { sceneUpdate(input: SceneUpdateInput!): Scene bulkSceneUpdate(input: BulkSceneUpdateInput!): [Scene!] sceneDestroy(input: SceneDestroyInput!): Boolean! + scenesDestroy(input: ScenesDestroyInput!): Boolean! scenesUpdate(input: [SceneUpdateInput!]!): [Scene] """Increments the o-counter for a scene. Returns the new value""" diff --git a/graphql/schema/types/scene.graphql b/graphql/schema/types/scene.graphql index 8afdd4b43..a7c6e7acd 100644 --- a/graphql/schema/types/scene.graphql +++ b/graphql/schema/types/scene.graphql @@ -99,6 +99,12 @@ input SceneDestroyInput { delete_generated: Boolean } +input ScenesDestroyInput { + ids: [ID!]! + delete_file: Boolean + delete_generated: Boolean +} + type FindScenesResultType { count: Int! scenes: [Scene!]! diff --git a/pkg/api/resolver_mutation_scene.go b/pkg/api/resolver_mutation_scene.go index b3d1ad485..75fea1f68 100644 --- a/pkg/api/resolver_mutation_scene.go +++ b/pkg/api/resolver_mutation_scene.go @@ -429,6 +429,47 @@ func (r *mutationResolver) SceneDestroy(ctx context.Context, input models.SceneD return true, nil } +func (r *mutationResolver) ScenesDestroy(ctx context.Context, input models.ScenesDestroyInput) (bool, error) { + qb := models.NewSceneQueryBuilder() + tx := database.DB.MustBeginTx(ctx, nil) + + var scenes []*models.Scene + for _, id := range input.Ids { + sceneID, _ := strconv.Atoi(id) + + scene, err := qb.Find(sceneID) + if scene != nil { + scenes = append(scenes, scene) + } + err = manager.DestroyScene(sceneID, tx) + + if err != nil { + tx.Rollback() + return false, err + } + } + + if err := tx.Commit(); err != nil { + return false, err + } + + for _, scene := range scenes { + // if delete generated is true, then delete the generated files + // for the scene + if input.DeleteGenerated != nil && *input.DeleteGenerated { + manager.DeleteGeneratedSceneFiles(scene) + } + + // if delete file is true, then delete the file as well + // if it fails, just log a message + if input.DeleteFile != nil && *input.DeleteFile { + manager.DeleteSceneFile(scene) + } + } + + return true, nil +} + func (r *mutationResolver) SceneMarkerCreate(ctx context.Context, input models.SceneMarkerCreateInput) (*models.SceneMarker, error) { primaryTagID, _ := strconv.Atoi(input.PrimaryTagID) sceneID, _ := strconv.Atoi(input.SceneID) diff --git a/ui/v2.5/src/components/Changelog/versions/v030.tsx b/ui/v2.5/src/components/Changelog/versions/v030.tsx index d2dae6b82..55525faa1 100644 --- a/ui/v2.5/src/components/Changelog/versions/v030.tsx +++ b/ui/v2.5/src/components/Changelog/versions/v030.tsx @@ -3,11 +3,13 @@ import ReactMarkdown from "react-markdown"; const markup = ` ### ✨ New Features +* Support deleting multiple scenes. * Add in-app help manual. * Add support for custom served folders. * Add support for parent/child studios. ### 🎨 Improvements +* Added multi-scene edit dialog. * Moved images to separate tables, increasing performance. * Add gallery grid view. * Add is-missing scene filter for gallery query. diff --git a/ui/v2.5/src/components/List/AddFilter.tsx b/ui/v2.5/src/components/List/AddFilter.tsx index 3b7b61bad..12e66ea7b 100644 --- a/ui/v2.5/src/components/List/AddFilter.tsx +++ b/ui/v2.5/src/components/List/AddFilter.tsx @@ -117,6 +117,7 @@ export const AddFilter: React.FC = ( as="select" onChange={onChangedModifierSelect} value={criterion.modifier} + className="btn-secondary" > {criterion.modifierOptions.map((c) => (