Fix new values not removed correctly when added (#1890)

* Fix new values not removed correctly when added
This commit is contained in:
WithoutPants 2021-10-27 09:33:08 +11:00 committed by GitHub
parent a822455a66
commit e9c7b0aed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 13 deletions

View file

@ -15,6 +15,7 @@
* Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816)) * Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816))
### 🐛 Bug fixes ### 🐛 Bug fixes
* Fix creating missing entities removing the incorrect entry from the missing list in the scrape dialog. ([#1890](https://github.com/stashapp/stash/pull/1890))
* Allow creating missing Studio during movie scrape. ([#1899](https://github.com/stashapp/stash/pull/1899)) * Allow creating missing Studio during movie scrape. ([#1899](https://github.com/stashapp/stash/pull/1899))
* Fix image files in folder galleries not being deleting when delete file option is checked. ([#1872](https://github.com/stashapp/stash/pull/1872)) * Fix image files in folder galleries not being deleting when delete file option is checked. ([#1872](https://github.com/stashapp/stash/pull/1872))
* Fix marker generation task reading video files unnecessarily. ([#1871](https://github.com/stashapp/stash/pull/1871)) * Fix marker generation task reading video files unnecessarily. ([#1871](https://github.com/stashapp/stash/pull/1871))

View file

@ -60,7 +60,9 @@ function renderScrapedStudioRow(
} }
onChange={onChange} onChange={onChange}
newValues={newStudio ? [newStudio] : undefined} newValues={newStudio ? [newStudio] : undefined}
onCreateNew={onCreateNew} onCreateNew={() => {
if (onCreateNew && newStudio) onCreateNew(newStudio);
}}
/> />
); );
} }
@ -112,7 +114,9 @@ function renderScrapedPerformersRow(
} }
onChange={onChange} onChange={onChange}
newValues={performersCopy} newValues={performersCopy}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newPerformers[i]);
}}
/> />
); );
} }
@ -159,7 +163,9 @@ function renderScrapedTagsRow(
} }
newValues={newTags} newValues={newTags}
onChange={onChange} onChange={onChange}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newTags[i]);
}}
/> />
); );
} }

View file

@ -54,7 +54,11 @@ function renderScrapedStudioRow(
} }
onChange={onChange} onChange={onChange}
newValues={newStudio ? [newStudio] : undefined} newValues={newStudio ? [newStudio] : undefined}
onCreateNew={onCreateNew} onCreateNew={() => {
if (onCreateNew && newStudio) {
onCreateNew(newStudio);
}
}}
/> />
); );
} }

View file

@ -112,7 +112,9 @@ function renderScrapedTagsRow(
} }
newValues={newTags} newValues={newTags}
onChange={onChange} onChange={onChange}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newTags[i]);
}}
/> />
); );
} }

View file

@ -63,7 +63,9 @@ function renderScrapedStudioRow(
} }
onChange={onChange} onChange={onChange}
newValues={newStudio ? [newStudio] : undefined} newValues={newStudio ? [newStudio] : undefined}
onCreateNew={onCreateNew} onCreateNew={() => {
if (onCreateNew && newStudio) onCreateNew(newStudio);
}}
/> />
); );
} }
@ -115,7 +117,9 @@ function renderScrapedPerformersRow(
} }
onChange={onChange} onChange={onChange}
newValues={performersCopy} newValues={performersCopy}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newPerformers[i]);
}}
/> />
); );
} }
@ -167,7 +171,9 @@ function renderScrapedMoviesRow(
} }
onChange={onChange} onChange={onChange}
newValues={moviesCopy} newValues={moviesCopy}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newMovies[i]);
}}
/> />
); );
} }
@ -214,7 +220,9 @@ function renderScrapedTagsRow(
} }
newValues={newTags} newValues={newTags}
onChange={onChange} onChange={onChange}
onCreateNew={onCreateNew} onCreateNew={(i) => {
if (onCreateNew) onCreateNew(newTags[i]);
}}
/> />
); );
} }

View file

@ -50,7 +50,7 @@ export class ScrapeResult<T> {
} }
interface IHasName { interface IHasName {
name: string; name: string | undefined;
} }
interface IScrapedFieldProps<T> { interface IScrapedFieldProps<T> {
@ -64,7 +64,7 @@ interface IScrapedRowProps<T, V extends IHasName>
renderNewField: (result: ScrapeResult<T>) => JSX.Element | undefined; renderNewField: (result: ScrapeResult<T>) => JSX.Element | undefined;
onChange: (value: ScrapeResult<T>) => void; onChange: (value: ScrapeResult<T>) => void;
newValues?: V[]; newValues?: V[];
onCreateNew?: (newValue: V) => void; onCreateNew?: (index: number) => void;
} }
function renderButtonIcon(selected: boolean) { function renderButtonIcon(selected: boolean) {
@ -102,12 +102,12 @@ export const ScrapeDialogRow = <T, V extends IHasName>(
const ret = ( const ret = (
<> <>
{props.newValues!.map((t) => ( {props.newValues!.map((t, i) => (
<Badge <Badge
className="tag-item" className="tag-item"
variant="secondary" variant="secondary"
key={t.name} key={t.name}
onClick={() => props.onCreateNew!(t)} onClick={() => props.onCreateNew!(i)}
> >
{t.name} {t.name}
<Button className="minimal ml-2"> <Button className="minimal ml-2">