Replace lodash difference, intersects, union

(re: 6087)
This commit is contained in:
Bryan Housel
2019-03-27 01:22:11 -04:00
parent c5c0d27c85
commit 5e1ff74199
26 changed files with 146 additions and 170 deletions
+18 -6
View File
@@ -1,6 +1,4 @@
import _forEach from 'lodash-es/forEach';
import _isEqual from 'lodash-es/isEqual';
import _unionBy from 'lodash-es/unionBy';
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { select as d3_select } from 'd3-selection';
@@ -389,9 +387,22 @@ export function uiCommit(context) {
context.storage('hashtags', null); // always remove stored hashtags - #4304
if (commentOnly) { inHashTags = null; } // optionally override hashtags field
}
return _unionBy(inComment, inHashTags, function (s) {
return s.toLowerCase();
});
// keep only one copy of the tags
var all = new Set();
var keepTags = [];
inComment.forEach(checkTag);
inHashTags.forEach(checkTag);
return keepTags;
// Compare tags as lowercase strings, but keep original case tags
function checkTag(s) {
var compare = s.toLowerCase();
if (!all.has(compare)) {
all.add(compare);
keepTags.push(s);
}
}
// Extract hashtags from `comment`
function commentTags() {
@@ -425,7 +436,8 @@ export function uiCommit(context) {
function updateChangeset(changed, onInput) {
var tags = Object.assign({}, _changeset.tags); // shallow copy
_forEach(changed, function(v, k) {
Object.keys(changed).forEach(function(k) {
var v = changed[k];
k = k.trim().substr(0, 255);
if (readOnlyTags.indexOf(k) !== -1) return;