]> cat aescling's git repositories - mastodon.git/commitdiff
Fix thinking_face emoji autocomplete (#5238)
authorNolan Lawson <nolan@nolanlawson.com>
Fri, 6 Oct 2017 10:03:13 +0000 (03:03 -0700)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 6 Oct 2017 10:03:13 +0000 (12:03 +0200)
app/javascript/mastodon/features/emoji/emoji_utils.js
spec/javascript/components/emoji_index.test.js

index 6ef2785d9a92c4bd1a62db8b3f815a449ce34bee..2742185d9c728fc8262e9181e8e13ced7adcd303 100644 (file)
@@ -125,13 +125,16 @@ function getData(emoji) {
 }
 
 function intersect(a, b) {
-  let aSet = new Set(a);
-  let bSet = new Set(b);
-  let intersection = new Set(
-    [...aSet].filter(x => bSet.has(x))
-  );
-
-  return Array.from(intersection);
+  let set;
+  let list;
+  if (a.length < b.length) {
+    set = new Set(a);
+    list = b;
+  } else {
+    set = new Set(b);
+    list = a;
+  }
+  return Array.from(new Set(list.filter(x => set.has(x))));
 }
 
 export { getData, getSanitizedData, intersect };
index 4bff7926500a1c65ec98257cbd2c44d4e6797f3c..07d26a685fc78f2679d2547dc8629f5550213be3 100644 (file)
@@ -96,4 +96,11 @@ describe('emoji_index', () => {
     expect(search('polo').map(trimEmojis)).to.deep.equal(expected);
     expect(emojiIndex.search('polo').map(trimEmojis)).to.deep.equal(expected);
   });
+
+  it('can search for thinking_face', () => {
+    let expected = [ { id: 'thinking_face', unified: '1f914', native: '🤔' } ];
+    expect(search('thinking_fac').map(trimEmojis)).to.deep.equal(expected);
+    // this is currently broken in emoji-mart
+    // expect(emojiIndex.search('thinking_fac').map(trimEmojis)).to.deep.equal(expected);
+  });
 });