Deduplicate emojis even after using multiple matchers

Fixes .
This commit is contained in:
Franz Liedke 2016-05-28 16:22:31 +09:00
parent dbf82e4641
commit 16f3a09856
2 changed files with 4 additions and 2 deletions
extensions/emoji/js/forum

@ -235,7 +235,8 @@ System.register('flarum/emoji/addComposerAutocomplete', ['flarum/extend', 'flaru
var findMatchingEmojis = function findMatchingEmojis(matcher) { var findMatchingEmojis = function findMatchingEmojis(matcher) {
for (var _i = 0; _i < emojiKeys.length && maxSuggestions > 0; _i++) { for (var _i = 0; _i < emojiKeys.length && maxSuggestions > 0; _i++) {
if (matcher(emojiKeys[_i])) { var curEmoji = emojiKeys[_i];
if (matcher(curEmoji) && similarEmoji.indexOf(curEmoji) === -1) {
--maxSuggestions; --maxSuggestions;
similarEmoji.push(emojiKeys[_i]); similarEmoji.push(emojiKeys[_i]);
} }

@ -106,7 +106,8 @@ export default function addComposerAutocomplete() {
const findMatchingEmojis = matcher => { const findMatchingEmojis = matcher => {
for (let i = 0; i < emojiKeys.length && maxSuggestions > 0; i++) { for (let i = 0; i < emojiKeys.length && maxSuggestions > 0; i++) {
if (matcher(emojiKeys[i])) { const curEmoji = emojiKeys[i];
if (matcher(curEmoji) && similarEmoji.indexOf(curEmoji) === -1) {
--maxSuggestions; --maxSuggestions;
similarEmoji.push(emojiKeys[i]); similarEmoji.push(emojiKeys[i]);
} }