mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Fix scraped studio not matching existing value (#4548)
* Fix scraped studio not matching existing * Fix incorrect key value
This commit is contained in:
@@ -6,14 +6,17 @@ import {
|
||||
IHasName,
|
||||
} from "src/components/Shared/ScrapeDialog/ScrapeDialog";
|
||||
import { PerformerSelect } from "src/components/Performers/PerformerSelect";
|
||||
import { ScrapeResult } from "src/components/Shared/ScrapeDialog/scrapeResult";
|
||||
import {
|
||||
ObjectScrapeResult,
|
||||
ScrapeResult,
|
||||
} from "src/components/Shared/ScrapeDialog/scrapeResult";
|
||||
import { TagSelect } from "src/components/Tags/TagSelect";
|
||||
import { StudioSelect } from "src/components/Studios/StudioSelect";
|
||||
|
||||
interface IScrapedStudioRow {
|
||||
title: string;
|
||||
result: ScrapeResult<GQL.ScrapedStudio>;
|
||||
onChange: (value: ScrapeResult<GQL.ScrapedStudio>) => void;
|
||||
result: ObjectScrapeResult<GQL.ScrapedStudio>;
|
||||
onChange: (value: ObjectScrapeResult<GQL.ScrapedStudio>) => void;
|
||||
newStudio?: GQL.ScrapedStudio;
|
||||
onCreateNew?: (value: GQL.ScrapedStudio) => void;
|
||||
}
|
||||
@@ -26,7 +29,7 @@ export const ScrapedStudioRow: React.FC<IScrapedStudioRow> = ({
|
||||
onCreateNew,
|
||||
}) => {
|
||||
function renderScrapedStudio(
|
||||
scrapeResult: ScrapeResult<GQL.ScrapedStudio>,
|
||||
scrapeResult: ObjectScrapeResult<GQL.ScrapedStudio>,
|
||||
isNew?: boolean,
|
||||
onChangeFn?: (value: GQL.ScrapedStudio) => void
|
||||
) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useStudioCreate,
|
||||
useTagCreate,
|
||||
} from "src/core/StashService";
|
||||
import { ScrapeResult } from "./scrapeResult";
|
||||
import { ObjectScrapeResult, ScrapeResult } from "./scrapeResult";
|
||||
import { useIntl } from "react-intl";
|
||||
import { scrapedPerformerToCreateInput } from "src/core/performers";
|
||||
import { scrapedMovieToCreateInput } from "src/core/movies";
|
||||
@@ -41,8 +41,10 @@ function useCreateObject<T>(
|
||||
}
|
||||
|
||||
interface IUseCreateNewStudioProps {
|
||||
scrapeResult: ScrapeResult<GQL.ScrapedStudio>;
|
||||
setScrapeResult: (scrapeResult: ScrapeResult<GQL.ScrapedStudio>) => void;
|
||||
scrapeResult: ObjectScrapeResult<GQL.ScrapedStudio>;
|
||||
setScrapeResult: (
|
||||
scrapeResult: ObjectScrapeResult<GQL.ScrapedStudio>
|
||||
) => void;
|
||||
setNewObject: (newObject: GQL.ScrapedStudio | undefined) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,23 @@ export class ObjectListScrapeResult<
|
||||
}
|
||||
}
|
||||
|
||||
export class ObjectScrapeResult<
|
||||
T extends IHasStoredID
|
||||
> extends ScrapeResult<T> {
|
||||
public constructor(
|
||||
originalValue?: T | null,
|
||||
newValue?: T | null,
|
||||
useNewValue?: boolean
|
||||
) {
|
||||
super(
|
||||
originalValue,
|
||||
newValue,
|
||||
useNewValue,
|
||||
(o1, o2) => o1?.stored_id === o2?.stored_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function hasScrapedValues(values: { scraped: boolean }[]): boolean {
|
||||
return values.some((r) => r.scraped);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user