diff --git a/src/cheogram/java/com/cheogram/android/EmojiSearch.java b/src/cheogram/java/com/cheogram/android/EmojiSearch.java index d2d4d4ac3b19bdcf1c92de6d8814f04386d4dcc7..c94422688b1c4fe0a31bdec23c476bad198290fb 100644 --- a/src/cheogram/java/com/cheogram/android/EmojiSearch.java +++ b/src/cheogram/java/com/cheogram/android/EmojiSearch.java @@ -62,6 +62,15 @@ public class EmojiSearch { } public synchronized void addEmoji(final Emoji one) { + if (one instanceof CustomEmoji) { + for (Emoji e : emoji) { + if (one.shortcodeMatch(e.uniquePart())) { + one.shortcodes.clear(); + one.shortcodes.addAll(e.shortcodes); + break; + } + } + } emoji.add(one); } @@ -76,18 +85,6 @@ public class EmojiSearch { pq.addTopK(e, Math.max(shortcodeScore, tagScore), 10); } - for (BoundExtractedResult r : new ArrayList<>(pq)) { - for (Emoji e : emoji) { - if (e.shortcodeMatch(r.getReferent().uniquePart())) { - // hack see https://stackoverflow.com/questions/76880072/imagespan-with-emojicompat - e.shortcodes.clear(); - e.shortcodes.addAll(r.getReferent().shortcodes); - - pq.addTopK(e, r.getScore() - 1, 10); - } - } - } - List result = new ArrayList<>(); for (int i = 0; i < 10; i++) { BoundExtractedResult e = pq.poll();