mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Wire up Tagger set tags checkbox (#889)
This commit is contained in:
@@ -59,6 +59,7 @@ interface IStashSearchResultProps {
|
|||||||
setScene: (scene: GQL.SlimSceneDataFragment) => void;
|
setScene: (scene: GQL.SlimSceneDataFragment) => void;
|
||||||
setCoverImage: boolean;
|
setCoverImage: boolean;
|
||||||
tagOperation: string;
|
tagOperation: string;
|
||||||
|
setTags: boolean;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
queueFingerprintSubmission: (sceneId: string, endpoint: string) => void;
|
queueFingerprintSubmission: (sceneId: string, endpoint: string) => void;
|
||||||
}
|
}
|
||||||
@@ -72,6 +73,7 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
|||||||
setScene,
|
setScene,
|
||||||
setCoverImage,
|
setCoverImage,
|
||||||
tagOperation,
|
tagOperation,
|
||||||
|
setTags,
|
||||||
endpoint,
|
endpoint,
|
||||||
queueFingerprintSubmission,
|
queueFingerprintSubmission,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -234,29 +236,33 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagIDs: string[] =
|
let updatedTags = stashScene?.tags?.map((t) => t.id) ?? [];
|
||||||
tagOperation === "merge"
|
if (setTags) {
|
||||||
? stashScene?.tags?.map((t) => t.id) ?? []
|
const newTagIDs = tagOperation === "merge" ? updatedTags : [];
|
||||||
: [];
|
const tags = scene.tags ?? [];
|
||||||
const tags = scene.tags ?? [];
|
if (tags.length > 0) {
|
||||||
if (tags.length > 0) {
|
const tagDict: Record<string, string> = (allTags?.allTagsSlim ?? [])
|
||||||
const tagDict: Record<string, string> = (allTags?.allTagsSlim ?? [])
|
.filter((t) => t.name)
|
||||||
.filter((t) => t.name)
|
.reduce(
|
||||||
.reduce((dict, t) => ({ ...dict, [t.name.toLowerCase()]: t.id }), {});
|
(dict, t) => ({ ...dict, [t.name.toLowerCase()]: t.id }),
|
||||||
const newTags: string[] = [];
|
{}
|
||||||
tags.forEach((tag) => {
|
);
|
||||||
if (tagDict[tag.name.toLowerCase()])
|
const newTags: string[] = [];
|
||||||
tagIDs.push(tagDict[tag.name.toLowerCase()]);
|
tags.forEach((tag) => {
|
||||||
else newTags.push(tag.name);
|
if (tagDict[tag.name.toLowerCase()])
|
||||||
});
|
newTagIDs.push(tagDict[tag.name.toLowerCase()]);
|
||||||
|
else newTags.push(tag.name);
|
||||||
|
});
|
||||||
|
|
||||||
const createdTags = await Promise.all(
|
const createdTags = await Promise.all(
|
||||||
newTags.map((tag) => createTag(tag))
|
newTags.map((tag) => createTag(tag))
|
||||||
);
|
);
|
||||||
createdTags.forEach((createdTag) => {
|
createdTags.forEach((createdTag) => {
|
||||||
if (createdTag?.data?.tagCreate?.id)
|
if (createdTag?.data?.tagCreate?.id)
|
||||||
tagIDs.push(createdTag.data.tagCreate.id);
|
newTagIDs.push(createdTag.data.tagCreate.id);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
updatedTags = uniq(newTagIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
const sceneUpdateResult = await updateScene({
|
const sceneUpdateResult = await updateScene({
|
||||||
@@ -269,7 +275,7 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
|
|||||||
studio_id: studioID,
|
studio_id: studioID,
|
||||||
cover_image: imgData,
|
cover_image: imgData,
|
||||||
url: scene.url,
|
url: scene.url,
|
||||||
...(tagIDs ? { tag_ids: uniq(tagIDs) } : {}),
|
tag_ids: updatedTags,
|
||||||
stash_ids: [
|
stash_ids: [
|
||||||
...(stashScene?.stash_ids ?? []),
|
...(stashScene?.stash_ids ?? []),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ const TaggerList: React.FC<ITaggerListProps> = ({
|
|||||||
setScene={handleTaggedScene}
|
setScene={handleTaggedScene}
|
||||||
scene={fingerprintMatch}
|
scene={fingerprintMatch}
|
||||||
setCoverImage={config.setCoverImage}
|
setCoverImage={config.setCoverImage}
|
||||||
|
setTags={config.setTags}
|
||||||
tagOperation={config.tagOperation}
|
tagOperation={config.tagOperation}
|
||||||
endpoint={selectedEndpoint.endpoint}
|
endpoint={selectedEndpoint.endpoint}
|
||||||
queueFingerprintSubmission={queueFingerprintSubmission}
|
queueFingerprintSubmission={queueFingerprintSubmission}
|
||||||
@@ -285,6 +286,7 @@ const TaggerList: React.FC<ITaggerListProps> = ({
|
|||||||
}
|
}
|
||||||
setCoverImage={config.setCoverImage}
|
setCoverImage={config.setCoverImage}
|
||||||
tagOperation={config.tagOperation}
|
tagOperation={config.tagOperation}
|
||||||
|
setTags={config.setTags}
|
||||||
setScene={handleTaggedScene}
|
setScene={handleTaggedScene}
|
||||||
endpoint={selectedEndpoint.endpoint}
|
endpoint={selectedEndpoint.endpoint}
|
||||||
queueFingerprintSubmission={queueFingerprintSubmission}
|
queueFingerprintSubmission={queueFingerprintSubmission}
|
||||||
|
|||||||
Reference in New Issue
Block a user