mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 01:35:11 +00:00
Merge pull request #3900 from lbryio/fix-csvTagsLoophole
csv tags sliced to limit
This commit is contained in:
commit
6cd5048572
1 changed files with 12 additions and 4 deletions
|
@ -30,6 +30,7 @@ type Props = {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function TagsSearch(props: Props) {
|
export default function TagsSearch(props: Props) {
|
||||||
|
const TAG_FOLLOW_MAX = 1000;
|
||||||
const {
|
const {
|
||||||
tagsPassedIn = [],
|
tagsPassedIn = [],
|
||||||
unfollowedTags = [],
|
unfollowedTags = [],
|
||||||
|
@ -43,7 +44,7 @@ export default function TagsSearch(props: Props) {
|
||||||
placeholder,
|
placeholder,
|
||||||
label,
|
label,
|
||||||
disabled,
|
disabled,
|
||||||
limitSelect,
|
limitSelect = TAG_FOLLOW_MAX,
|
||||||
limitShow = 5,
|
limitShow = 5,
|
||||||
} = props;
|
} = props;
|
||||||
const [newTag, setNewTag] = useState('');
|
const [newTag, setNewTag] = useState('');
|
||||||
|
@ -86,7 +87,14 @@ export default function TagsSearch(props: Props) {
|
||||||
|
|
||||||
setNewTag('');
|
setNewTag('');
|
||||||
|
|
||||||
const newTagsArr = Array.from(new Set(tags.split(',').map(newTag => newTag.trim().toLowerCase())));
|
const newTagsArr = Array.from(
|
||||||
|
new Set(
|
||||||
|
tags
|
||||||
|
.split(',')
|
||||||
|
.slice(0, limitSelect - countWithoutMature)
|
||||||
|
.map(newTag => newTag.trim().toLowerCase())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Split into individual tags, normalize the tags, and remove duplicates with a set.
|
// Split into individual tags, normalize the tags, and remove duplicates with a set.
|
||||||
if (onSelect) {
|
if (onSelect) {
|
||||||
|
@ -118,10 +126,10 @@ export default function TagsSearch(props: Props) {
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Form className="tags__input-wrapper" onSubmit={handleSubmit}>
|
<Form className="tags__input-wrapper" onSubmit={handleSubmit}>
|
||||||
<label>
|
<label>
|
||||||
{limitSelect ? (
|
{limitSelect < TAG_FOLLOW_MAX ? (
|
||||||
<I18nMessage
|
<I18nMessage
|
||||||
tokens={{
|
tokens={{
|
||||||
number: 5 - countWithoutMature,
|
number: limitSelect - countWithoutMature,
|
||||||
selectTagsLabel: label,
|
selectTagsLabel: label,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Reference in a new issue