Fix #4731: Tag counter in edit boxes should only count unique tags, not repeated.

Just use the `uniq` function from lodash. Adds ~1kb to the build.

Also rename `Utility.regexp_split` to `Utility.splitWords`.
This commit is contained in:
evazion
2021-02-23 18:49:53 -06:00
parent 868f1a1809
commit b2a423af64
6 changed files with 29 additions and 17 deletions

View File

@@ -15,7 +15,9 @@ Blacklist.parse_entry = function(string) {
"hits": 0,
"min_score": null
};
Utility.regexp_split(string).forEach(function(tag) {
let tags = Utility.splitWords(string);
tags.forEach(function(tag) {
if (tag.charAt(0) === '-') {
entry.exclude.push(tag.slice(1));
} else if (tag.charAt(0) === '~') {
@@ -171,11 +173,11 @@ Blacklist.post_match = function(post, entry) {
var score = parseInt($post.attr("data-score"));
var score_test = entry.min_score === null || score < entry.min_score;
var tags = Utility.regexp_split($post.attr("data-tags"));
tags.push(...Utility.regexp_split($post.attr("data-pools")));
var tags = Utility.splitWords($post.attr("data-tags"));
tags.push(...Utility.splitWords($post.attr("data-pools")));
tags.push("rating:" + $post.data("rating"));
tags.push("uploaderid:" + $post.attr("data-uploader-id"));
Utility.regexp_split($post.data("flags")).forEach(function(v) {
Utility.splitWords($post.data("flags")).forEach(function(v) {
tags.push("status:" + v);
});