mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Merge studio stash ids (#4572)
This commit is contained in:
@@ -25,6 +25,7 @@ import { useToast } from "src/hooks/Toast";
|
|||||||
import { ConfigurationContext } from "src/hooks/Config";
|
import { ConfigurationContext } from "src/hooks/Config";
|
||||||
import { ITaggerSource, SCRAPER_PREFIX, STASH_BOX_PREFIX } from "./constants";
|
import { ITaggerSource, SCRAPER_PREFIX, STASH_BOX_PREFIX } from "./constants";
|
||||||
import { errorToString } from "src/utils";
|
import { errorToString } from "src/utils";
|
||||||
|
import { mergeStudioStashIDs } from "./utils";
|
||||||
|
|
||||||
export interface ITaggerContextState {
|
export interface ITaggerContextState {
|
||||||
config: ITaggerConfig;
|
config: ITaggerConfig;
|
||||||
@@ -708,6 +709,11 @@ export const TaggerContext: React.FC = ({ children }) => {
|
|||||||
|
|
||||||
async function updateExistingStudio(input: GQL.StudioUpdateInput) {
|
async function updateExistingStudio(input: GQL.StudioUpdateInput) {
|
||||||
try {
|
try {
|
||||||
|
const inputCopy = { ...input };
|
||||||
|
inputCopy.stash_ids = await mergeStudioStashIDs(
|
||||||
|
input.id,
|
||||||
|
input.stash_ids ?? []
|
||||||
|
);
|
||||||
const result = await updateStudio({
|
const result = await updateStudio({
|
||||||
variables: {
|
variables: {
|
||||||
input: input,
|
input: input,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { faTags } from "@fortawesome/free-solid-svg-icons";
|
|||||||
import { useStudioCreate } from "src/core/StashService";
|
import { useStudioCreate } from "src/core/StashService";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
import { apolloError } from "src/utils";
|
import { apolloError } from "src/utils";
|
||||||
|
import { mergeStudioStashIDs } from "../utils";
|
||||||
|
|
||||||
interface IStashSearchResultProps {
|
interface IStashSearchResultProps {
|
||||||
studio: GQL.SlimStudioDataFragment;
|
studio: GQL.SlimStudioDataFragment;
|
||||||
@@ -69,6 +70,12 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
|||||||
...parentInput,
|
...parentInput,
|
||||||
id: input.parent_id,
|
id: input.parent_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
parentUpdateData.stash_ids = await mergeStudioStashIDs(
|
||||||
|
input.parent_id,
|
||||||
|
parentInput.stash_ids ?? []
|
||||||
|
);
|
||||||
|
|
||||||
await updateStudio(parentUpdateData);
|
await updateStudio(parentUpdateData);
|
||||||
} else {
|
} else {
|
||||||
const parentRes = await createStudio({
|
const parentRes = await createStudio({
|
||||||
@@ -87,6 +94,11 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
|||||||
id: studio.id,
|
id: studio.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateData.stash_ids = await mergeStudioStashIDs(
|
||||||
|
studio.id,
|
||||||
|
input.stash_ids ?? []
|
||||||
|
);
|
||||||
|
|
||||||
const res = await updateStudio(updateData);
|
const res = await updateStudio(updateData);
|
||||||
|
|
||||||
if (!res?.data?.studioUpdate)
|
if (!res?.data?.studioUpdate)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { useUpdateStudio } from "../queries";
|
|||||||
import { apolloError } from "src/utils";
|
import { apolloError } from "src/utils";
|
||||||
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
|
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { ExternalLink } from "src/components/Shared/ExternalLink";
|
import { ExternalLink } from "src/components/Shared/ExternalLink";
|
||||||
|
import { mergeStudioStashIDs } from "../utils";
|
||||||
|
|
||||||
type JobFragment = Pick<
|
type JobFragment = Pick<
|
||||||
GQL.Job,
|
GQL.Job,
|
||||||
@@ -426,6 +427,10 @@ const StudioTaggerList: React.FC<IStudioTaggerListProps> = ({
|
|||||||
...parentInput,
|
...parentInput,
|
||||||
id: input.parent_id,
|
id: input.parent_id,
|
||||||
};
|
};
|
||||||
|
parentUpdateData.stash_ids = await mergeStudioStashIDs(
|
||||||
|
input.parent_id,
|
||||||
|
parentInput.stash_ids ?? []
|
||||||
|
);
|
||||||
await updateStudio(parentUpdateData);
|
await updateStudio(parentUpdateData);
|
||||||
} else {
|
} else {
|
||||||
const parentRes = await createStudio({
|
const parentRes = await createStudio({
|
||||||
@@ -442,6 +447,10 @@ const StudioTaggerList: React.FC<IStudioTaggerListProps> = ({
|
|||||||
...input,
|
...input,
|
||||||
id: studioID,
|
id: studioID,
|
||||||
};
|
};
|
||||||
|
updateData.stash_ids = await mergeStudioStashIDs(
|
||||||
|
studioID,
|
||||||
|
input.stash_ids ?? []
|
||||||
|
);
|
||||||
|
|
||||||
const res = await updateStudio(updateData);
|
const res = await updateStudio(updateData);
|
||||||
if (!res.data?.studioUpdate)
|
if (!res.data?.studioUpdate)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import * as GQL from "src/core/generated-graphql";
|
import * as GQL from "src/core/generated-graphql";
|
||||||
import { ParseMode } from "./constants";
|
import { ParseMode } from "./constants";
|
||||||
|
import { queryFindStudio } from "src/core/StashService";
|
||||||
|
import { mergeStashIDs } from "src/utils/stashbox";
|
||||||
|
|
||||||
const months = [
|
const months = [
|
||||||
"jan",
|
"jan",
|
||||||
@@ -142,3 +144,15 @@ export const parsePath = (filePath: string) => {
|
|||||||
|
|
||||||
return { paths, file, ext };
|
return { paths, file, ext };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function mergeStudioStashIDs(
|
||||||
|
id: string,
|
||||||
|
newStashIDs: GQL.StashIdInput[]
|
||||||
|
) {
|
||||||
|
const existing = await queryFindStudio(id);
|
||||||
|
if (existing?.data?.findStudio?.stash_ids) {
|
||||||
|
return mergeStashIDs(existing.data.findStudio.stash_ids, newStashIDs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newStashIDs;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user