Fix scraped tags issues (#5522)

* Fix display of matched scraped tags
* Fix create new scraped tag not updating field correctly
This commit is contained in:
WithoutPants
2024-12-03 08:02:29 +11:00
committed by GitHub
parent 60bb6bf50b
commit 4be793d4b3

View File

@@ -44,10 +44,15 @@ export function useTagsEdit(
}
// add the new tag to the new tags value
const newTagIds = tags
.map((t) => t.id)
.concat([result.data.tagCreate.id]);
setFieldValue(newTagIds);
onSetTags(
tags.concat([
{
id: result.data.tagCreate.id,
name: toCreate.name ?? "",
aliases: [],
},
])
);
// remove the tag from the list
const newTagsClone = newTags!.concat();
@@ -73,10 +78,17 @@ export function useTagsEdit(
function updateTagsStateFromScraper(
scrapedTags?: Pick<GQL.ScrapedTag, "name" | "stored_id">[]
) {
if (scrapedTags) {
if (!scrapedTags) {
return;
}
// map tags to their ids and filter out those not found
const idTags = scrapedTags.filter(
(t) => t.stored_id !== undefined && t.stored_id !== null
);
const newNewTags = scrapedTags.filter((t) => !t.stored_id);
onSetTags(
scrapedTags.map((p) => {
idTags.map((p) => {
return {
id: p.stored_id!,
name: p.name ?? "",
@@ -85,8 +97,7 @@ export function useTagsEdit(
})
);
setNewTags(scrapedTags.filter((t) => !t.stored_id));
}
setNewTags(newNewTags);
}
function renderNewTags() {