Fix incorrect performer data being sent and submitted when multiple stash-box endpoints configured (#3543)

* Show performer stash id for selected instance
* Fix incorrect select value in SubmitDraft modal
This commit is contained in:
WithoutPants
2023-03-20 10:30:41 +11:00
committed by GitHub
parent 4f909d2457
commit c1ca34303e
2 changed files with 56 additions and 55 deletions

View File

@@ -96,6 +96,7 @@ export const SubmitStashBoxDraft: React.FC<IProps> = ({
<Form.Control <Form.Control
as="select" as="select"
onChange={handleSelectBox} onChange={handleSelectBox}
value={selectedBoxIndex}
className="col-6 input-control" className="col-6 input-control"
> >
{boxes.map((box, i) => ( {boxes.map((box, i) => (

View File

@@ -379,10 +379,13 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
const renderPerformers = () => const renderPerformers = () =>
performers.map((performer) => { performers.map((performer) => {
const isTagged = taggedPerformers[performer.id]; const isTagged = taggedPerformers[performer.id];
const hasStashIDs = performer.stash_ids.length > 0;
const stashID = performer.stash_ids.find((s) => {
return s.endpoint === selectedEndpoint.endpoint;
});
let mainContent; let mainContent;
if (!isTagged && hasStashIDs) { if (!isTagged && stashID !== undefined) {
mainContent = ( mainContent = (
<div className="text-left"> <div className="text-left">
<h5 className="text-bold"> <h5 className="text-bold">
@@ -390,7 +393,7 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
</h5> </h5>
</div> </div>
); );
} else if (!isTagged && !hasStashIDs) { } else if (!isTagged && !stashID) {
mainContent = ( mainContent = (
<InputGroup> <InputGroup>
<Form.Control <Form.Control
@@ -441,8 +444,7 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
} }
let subContent; let subContent;
if (performer.stash_ids.length > 0) { if (stashID !== undefined) {
const stashLinks = performer.stash_ids.map((stashID) => {
const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0]; const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0];
const link = base ? ( const link = base ? (
<a <a
@@ -457,19 +459,19 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
<div className="small">{stashID.stash_id}</div> <div className="small">{stashID.stash_id}</div>
); );
const endpoint = const endpointIndex =
stashBoxes?.findIndex((box) => box.endpoint === stashID.endpoint) ?? stashBoxes?.findIndex((box) => box.endpoint === stashID.endpoint) ??
-1; -1;
return ( subContent = (
<div key={performer.id}> <div key={performer.id}>
<InputGroup className="PerformerTagger-box-link"> <InputGroup className="PerformerTagger-box-link">
<InputGroup.Text>{link}</InputGroup.Text> <InputGroup.Text>{link}</InputGroup.Text>
<InputGroup.Append> <InputGroup.Append>
{endpoint !== -1 && ( {endpointIndex !== -1 && (
<Button <Button
onClick={() => onClick={() =>
doBoxUpdate(performer.id, stashID.stash_id, endpoint) doBoxUpdate(performer.id, stashID.stash_id, endpointIndex)
} }
disabled={!!loadingUpdate} disabled={!!loadingUpdate}
> >
@@ -493,8 +495,6 @@ const PerformerTaggerList: React.FC<IPerformerTaggerListProps> = ({
)} )}
</div> </div>
); );
});
subContent = <>{stashLinks}</>;
} else if (searchErrors[performer.id]) { } else if (searchErrors[performer.id]) {
subContent = ( subContent = (
<div className="text-danger font-weight-bold"> <div className="text-danger font-weight-bold">