mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Fix performer stash ids being overwritten in performer tagger (#4215)
This commit is contained in:
parent
5e0f27bed2
commit
a9ab1fcca7
3 changed files with 28 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ import { LOCAL_FORAGE_KEY, ITaggerConfig, initialConfig } from "../constants";
|
||||||
import PerformerModal from "../PerformerModal";
|
import PerformerModal from "../PerformerModal";
|
||||||
import { useUpdatePerformer } from "../queries";
|
import { useUpdatePerformer } from "../queries";
|
||||||
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
|
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { mergeStashIDs } from "src/utils/stashbox";
|
||||||
|
|
||||||
type JobFragment = Pick<
|
type JobFragment = Pick<
|
||||||
GQL.Job,
|
GQL.Job,
|
||||||
|
|
@ -367,10 +368,18 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePerformerUpdate = async (input: GQL.PerformerCreateInput) => {
|
const handlePerformerUpdate = async (
|
||||||
|
existing: GQL.PerformerDataFragment,
|
||||||
|
input: GQL.PerformerCreateInput
|
||||||
|
) => {
|
||||||
setModalPerformer(undefined);
|
setModalPerformer(undefined);
|
||||||
const performerID = modalPerformer?.stored_id;
|
const performerID = modalPerformer?.stored_id;
|
||||||
if (performerID) {
|
if (performerID) {
|
||||||
|
// handle stash ids - we want to add, not set them
|
||||||
|
if (input.stash_ids?.length) {
|
||||||
|
input.stash_ids = mergeStashIDs(existing.stash_ids, input.stash_ids);
|
||||||
|
}
|
||||||
|
|
||||||
const updateData: GQL.PerformerUpdateInput = {
|
const updateData: GQL.PerformerUpdateInput = {
|
||||||
...input,
|
...input,
|
||||||
id: performerID,
|
id: performerID,
|
||||||
|
|
@ -540,7 +549,9 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
|
||||||
closeModal={() => setModalPerformer(undefined)}
|
closeModal={() => setModalPerformer(undefined)}
|
||||||
modalVisible={modalPerformer.stored_id === performer.id}
|
modalVisible={modalPerformer.stored_id === performer.id}
|
||||||
performer={modalPerformer}
|
performer={modalPerformer}
|
||||||
onSave={handlePerformerUpdate}
|
onSave={(input) => {
|
||||||
|
handlePerformerUpdate(performer, input);
|
||||||
|
}}
|
||||||
excludedPerformerFields={config.excludedPerformerFields}
|
excludedPerformerFields={config.excludedPerformerFields}
|
||||||
icon={faTags}
|
icon={faTags}
|
||||||
header={intl.formatMessage({
|
header={intl.formatMessage({
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import * as GQL from "src/core/generated-graphql";
|
||||||
import { useUpdatePerformer } from "../queries";
|
import { useUpdatePerformer } from "../queries";
|
||||||
import PerformerModal from "../PerformerModal";
|
import PerformerModal from "../PerformerModal";
|
||||||
import { faTags } from "@fortawesome/free-solid-svg-icons";
|
import { faTags } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { mergeStashIDs } from "src/utils/stashbox";
|
||||||
|
|
||||||
interface IStashSearchResultProps {
|
interface IStashSearchResultProps {
|
||||||
performer: GQL.SlimPerformerDataFragment;
|
performer: GQL.SlimPerformerDataFragment;
|
||||||
|
|
@ -38,6 +39,10 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
||||||
setSaveState("Saving performer");
|
setSaveState("Saving performer");
|
||||||
setModalPerformer(undefined);
|
setModalPerformer(undefined);
|
||||||
|
|
||||||
|
if (input.stash_ids?.length) {
|
||||||
|
input.stash_ids = mergeStashIDs(performer.stash_ids, input.stash_ids);
|
||||||
|
}
|
||||||
|
|
||||||
const updateData: GQL.PerformerUpdateInput = {
|
const updateData: GQL.PerformerUpdateInput = {
|
||||||
...input,
|
...input,
|
||||||
id: performer.id,
|
id: performer.id,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
|
import { StashIdInput } from "src/core/generated-graphql";
|
||||||
|
|
||||||
export function stashboxDisplayName(name: string, index: number) {
|
export function stashboxDisplayName(name: string, index: number) {
|
||||||
return name || `Stash-Box #${index + 1}`;
|
return name || `Stash-Box #${index + 1}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStashboxBase = (endpoint: string) =>
|
export const getStashboxBase = (endpoint: string) =>
|
||||||
endpoint.match(/(https?:\/\/.*?\/)graphql/)?.[1];
|
endpoint.match(/(https?:\/\/.*?\/)graphql/)?.[1];
|
||||||
|
|
||||||
|
// mergeStashIDs merges the src stash ID into the dest stash IDs.
|
||||||
|
// If the src stash ID is already in dest, the src stash ID overwrites the dest stash ID.
|
||||||
|
export function mergeStashIDs(dest: StashIdInput[], src: StashIdInput[]) {
|
||||||
|
return dest
|
||||||
|
.filter((i) => !src.find((j) => i.endpoint === j.endpoint))
|
||||||
|
.concat(src);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue