From c04174497ba2f14831d6e693b94b2974d1bbe44b Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:47:50 +1100 Subject: [PATCH] Fix display of matched scraped tags --- ui/v2.5/src/hooks/tagsEdit.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/v2.5/src/hooks/tagsEdit.tsx b/ui/v2.5/src/hooks/tagsEdit.tsx index 73d6c951d95..4b8bd80a165 100644 --- a/ui/v2.5/src/hooks/tagsEdit.tsx +++ b/ui/v2.5/src/hooks/tagsEdit.tsx @@ -73,10 +73,17 @@ export function useTagsEdit( function updateTagsStateFromScraper( scrapedTags?: Pick[] ) { - 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 +92,7 @@ export function useTagsEdit( }) ); - setNewTags(scrapedTags.filter((t) => !t.stored_id)); - } + setNewTags(newNewTags); } function renderNewTags() {