diff --git a/lbry/lbry/schema/attrs.py b/lbry/lbry/schema/attrs.py index 0f883950a..79aee897c 100644 --- a/lbry/lbry/schema/attrs.py +++ b/lbry/lbry/schema/attrs.py @@ -540,17 +540,11 @@ class TagList(BaseMessageList[str]): __slots__ = () item_class = str - @classmethod - def create_normalized(cls, message): - message[:] = clean_tags(message) - return cls(message) - def append(self, tag: str): tag = normalize_tag(tag) - if tag not in self._message: - self._message.append(tag) + if tag and tag not in self.message: + self.message.append(tag) def extend(self, tags: List[str]): - tags = clean_tags(tags) - tags = list(set(tags).difference(set(self._message))) - self._message.extend(tags) + for tag in tags: + self.append(tag) diff --git a/lbry/lbry/schema/claim.py b/lbry/lbry/schema/claim.py index 28d02d457..2a8033333 100644 --- a/lbry/lbry/schema/claim.py +++ b/lbry/lbry/schema/claim.py @@ -167,10 +167,6 @@ class BaseClaim: def tags(self) -> List[str]: return TagList(self.claim.message.tags) - @tags.setter - def tags(self, tags: List[str]): - self.claim.message.tags = TagList.create_normalized(tags) - @property def languages(self) -> LanguageList: return LanguageList(self.claim.message.languages) diff --git a/lbry/lbry/schema/tags.py b/lbry/lbry/schema/tags.py index ce6ee1875..3f1f93053 100644 --- a/lbry/lbry/schema/tags.py +++ b/lbry/lbry/schema/tags.py @@ -10,4 +10,9 @@ def normalize_tag(tag: str): def clean_tags(tags: List[str]): - return [tag for tag in set(normalize_tag(tag) for tag in tags) if tag] + clean = [] + for ind, tag in enumerate(tags): + norm_tag = normalize_tag(tag) + if norm_tag and norm_tag not in clean[:ind]: + clean.append(norm_tag) + return clean