mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 21:04:37 +03:00
Fix galleryCreate mutation (#1004)
This commit is contained in:
@@ -1,26 +1,7 @@
|
|||||||
mutation GalleryCreate(
|
mutation GalleryCreate(
|
||||||
$title: String!,
|
$input: GalleryCreateInput!) {
|
||||||
$details: String,
|
|
||||||
$url: String,
|
|
||||||
$date: String,
|
|
||||||
$rating: Int,
|
|
||||||
$organized: Boolean,
|
|
||||||
$scene_id: ID,
|
|
||||||
$studio_id: ID,
|
|
||||||
$performer_ids: [ID!] = [],
|
|
||||||
$tag_ids: [ID!] = []) {
|
|
||||||
|
|
||||||
galleryCreate(input: {
|
galleryCreate(input: $input) {
|
||||||
title: $title,
|
|
||||||
details: $details,
|
|
||||||
url: $url,
|
|
||||||
date: $date,
|
|
||||||
rating: $rating,
|
|
||||||
scene_id: $scene_id,
|
|
||||||
studio_id: $studio_id,
|
|
||||||
tag_ids: $tag_ids,
|
|
||||||
performer_ids: $performer_ids
|
|
||||||
}) {
|
|
||||||
...GalleryData
|
...GalleryData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ export const GalleryEditPanel: React.FC<
|
|||||||
// Network state
|
// Network state
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
const [createGallery] = useGalleryCreate(
|
const [createGallery] = useGalleryCreate();
|
||||||
getGalleryInput() as GQL.GalleryCreateInput
|
|
||||||
);
|
|
||||||
const [updateGallery] = useGalleryUpdate();
|
const [updateGallery] = useGalleryUpdate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -129,7 +127,7 @@ export const GalleryEditPanel: React.FC<
|
|||||||
function getGalleryInput() {
|
function getGalleryInput() {
|
||||||
return {
|
return {
|
||||||
id: props.isNew ? undefined : props.gallery.id,
|
id: props.isNew ? undefined : props.gallery.id,
|
||||||
title,
|
title: title ?? "",
|
||||||
details,
|
details,
|
||||||
url,
|
url,
|
||||||
date,
|
date,
|
||||||
@@ -144,7 +142,11 @@ export const GalleryEditPanel: React.FC<
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
if (props.isNew) {
|
if (props.isNew) {
|
||||||
const result = await createGallery();
|
const result = await createGallery({
|
||||||
|
variables: {
|
||||||
|
input: getGalleryInput(),
|
||||||
|
},
|
||||||
|
});
|
||||||
if (result.data?.galleryCreate) {
|
if (result.data?.galleryCreate) {
|
||||||
history.push(`/galleries/${result.data.galleryCreate.id}`);
|
history.push(`/galleries/${result.data.galleryCreate.id}`);
|
||||||
Toast.success({ content: "Created gallery" });
|
Toast.success({ content: "Created gallery" });
|
||||||
|
|||||||
@@ -499,9 +499,8 @@ const galleryMutationImpactedQueries = [
|
|||||||
GQL.FindGalleriesDocument,
|
GQL.FindGalleriesDocument,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const useGalleryCreate = (input: GQL.GalleryCreateInput) =>
|
export const useGalleryCreate = () =>
|
||||||
GQL.useGalleryCreateMutation({
|
GQL.useGalleryCreateMutation({
|
||||||
variables: input,
|
|
||||||
update: deleteCache(galleryMutationImpactedQueries),
|
update: deleteCache(galleryMutationImpactedQueries),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user