Fix performer stash ids being overwritten in performer tagger (#4215)

This commit is contained in:
WithoutPants
2023-10-17 11:42:57 +11:00
committed by GitHub
parent 5e0f27bed2
commit a9ab1fcca7
3 changed files with 28 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ import { LOCAL_FORAGE_KEY, ITaggerConfig, initialConfig } from "../constants";
import PerformerModal from "../PerformerModal";
import { useUpdatePerformer } from "../queries";
import { faStar, faTags } from "@fortawesome/free-solid-svg-icons";
import { mergeStashIDs } from "src/utils/stashbox";
type JobFragment = Pick<
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);
const performerID = modalPerformer?.stored_id;
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 = {
...input,
id: performerID,
@@ -540,7 +549,9 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
closeModal={() => setModalPerformer(undefined)}
modalVisible={modalPerformer.stored_id === performer.id}
performer={modalPerformer}
onSave={handlePerformerUpdate}
onSave={(input) => {
handlePerformerUpdate(performer, input);
}}
excludedPerformerFields={config.excludedPerformerFields}
icon={faTags}
header={intl.formatMessage({

View File

@@ -5,6 +5,7 @@ import * as GQL from "src/core/generated-graphql";
import { useUpdatePerformer } from "../queries";
import PerformerModal from "../PerformerModal";
import { faTags } from "@fortawesome/free-solid-svg-icons";
import { mergeStashIDs } from "src/utils/stashbox";
interface IStashSearchResultProps {
performer: GQL.SlimPerformerDataFragment;
@@ -38,6 +39,10 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
setSaveState("Saving performer");
setModalPerformer(undefined);
if (input.stash_ids?.length) {
input.stash_ids = mergeStashIDs(performer.stash_ids, input.stash_ids);
}
const updateData: GQL.PerformerUpdateInput = {
...input,
id: performer.id,