Merge pull request #2612 from lbryio/tags

fix: prevent duplicate tags on publish form
This commit is contained in:
Sean Yesmunt 2019-07-08 23:20:42 -04:00 committed by GitHub
commit 3447909c23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -136,7 +136,14 @@ function PublishForm(props: Props) {
suggestMature
help={__('The better your tags are, the easier it will be for people to discover your content.')}
empty={__('No tags added')}
onSelect={tag => updatePublishForm({ tags: [...tags, tag] })}
onSelect={newTag => {
if (!tags.map(savedTag => savedTag.name).includes(newTag.name)) {
updatePublishForm({ tags: [...tags, newTag] });
} else {
// If it already exists and the user types it in, remove it
updatePublishForm({ tags: tags.filter(tag => tag.name !== newTag.name) });
}
}}
onRemove={clickedTag => {
const newTags = tags.slice().filter(tag => tag.name !== clickedTag.name);
updatePublishForm({ tags: newTags });

View file

@ -532,4 +532,4 @@
"View Your Feed": "View Your Feed",
"View Your Channels": "View Your Channels",
"Unfollow": "Unfollow"
}
}