mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +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 { ITaggerSource, SCRAPER_PREFIX, STASH_BOX_PREFIX } from "./constants";
|
||||
import { errorToString } from "src/utils";
|
||||
import { mergeStudioStashIDs } from "./utils";
|
||||
|
||||
export interface ITaggerContextState {
|
||||
config: ITaggerConfig;
|
||||
@@ -708,6 +709,11 @@ export const TaggerContext: React.FC = ({ children }) => {
|
||||
|
||||
async function updateExistingStudio(input: GQL.StudioUpdateInput) {
|
||||
try {
|
||||
const inputCopy = { ...input };
|
||||
inputCopy.stash_ids = await mergeStudioStashIDs(
|
||||
input.id,
|
||||
input.stash_ids ?? []
|
||||
);
|
||||
const result = await updateStudio({
|
||||
variables: {
|
||||
input: input,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { faTags } from "@fortawesome/free-solid-svg-icons";
|
||||
import { useStudioCreate } from "src/core/StashService";
|
||||
import { useIntl } from "react-intl";
|
||||
import { apolloError } from "src/utils";
|
||||
import { mergeStudioStashIDs } from "../utils";
|
||||
|
||||
interface IStashSearchResultProps {
|
||||
studio: GQL.SlimStudioDataFragment;
|
||||
@@ -69,6 +70,12 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
||||
...parentInput,
|
||||
id: input.parent_id,
|
||||
};
|
||||
|
||||
parentUpdateData.stash_ids = await mergeStudioStashIDs(
|
||||
input.parent_id,
|
||||
parentInput.stash_ids ?? []
|
||||
);
|
||||
|
||||
await updateStudio(parentUpdateData);
|
||||
} else {
|
||||
const parentRes = await createStudio({
|
||||
@@ -87,6 +94,11 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
||||
id: studio.id,
|
||||
};
|
||||
|
||||
updateData.stash_ids = await mergeStudioStashIDs(
|
||||
studio.id,
|
||||
input.stash_ids ?? []
|
||||
);
|
||||
|
||||
const res = await updateStudio(updateData);
|
||||
|
||||
if (!res?.data?.studioUpdate)
|
||||
|
||||
@@ -28,6 +28,7 @@ import { useUpdateStudio } from "../queries";
|
||||
import { apolloError } from "src/utils";
|
||||
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
|
||||
import { ExternalLink } from "src/components/Shared/ExternalLink";
|
||||
import { mergeStudioStashIDs } from "../utils";
|
||||
|
||||
type JobFragment = Pick<
|
||||
GQL.Job,
|
||||
@@ -426,6 +427,10 @@ const StudioTaggerList: React.FC<IStudioTaggerListProps> = ({
|
||||
...parentInput,
|
||||
id: input.parent_id,
|
||||
};
|
||||
parentUpdateData.stash_ids = await mergeStudioStashIDs(
|
||||
input.parent_id,
|
||||
parentInput.stash_ids ?? []
|
||||
);
|
||||
await updateStudio(parentUpdateData);
|
||||
} else {
|
||||
const parentRes = await createStudio({
|
||||
@@ -442,6 +447,10 @@ const StudioTaggerList: React.FC<IStudioTaggerListProps> = ({
|
||||
...input,
|
||||
id: studioID,
|
||||
};
|
||||
updateData.stash_ids = await mergeStudioStashIDs(
|
||||
studioID,
|
||||
input.stash_ids ?? []
|
||||
);
|
||||
|
||||
const res = await updateStudio(updateData);
|
||||
if (!res.data?.studioUpdate)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as GQL from "src/core/generated-graphql";
|
||||
import { ParseMode } from "./constants";
|
||||
import { queryFindStudio } from "src/core/StashService";
|
||||
import { mergeStashIDs } from "src/utils/stashbox";
|
||||
|
||||
const months = [
|
||||
"jan",
|
||||
@@ -142,3 +144,15 @@ export const parsePath = (filePath: string) => {
|
||||
|
||||
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