Skip to content

Commit

Permalink
Fix create new scraped tag not updating field correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Dec 2, 2024
1 parent c041744 commit 3202882
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions ui/v2.5/src/hooks/tagsEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -77,20 +82,20 @@ export function useTagsEdit(
return;
}

// map tags to their ids and filter out those not found
// 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(
onSetTags(
idTags.map((p) => {
return {
id: p.stored_id!,
name: p.name ?? "",
aliases: [],
};
})
);
return {
id: p.stored_id!,
name: p.name ?? "",
aliases: [],
};
})
);

setNewTags(newNewTags);
}
Expand Down

0 comments on commit 3202882

Please sign in to comment.