From d8547e4377dbf43d2ba75da215af6aa1eadae40d Mon Sep 17 00:00:00 2001 From: Alexandru Mihai <92.alexandru.mihai@gmail.com> Date: Wed, 21 Oct 2015 02:09:39 +0300 Subject: [PATCH] Fixed #1140 added ascii emoji to autocomplete and sorted them --- client/views/app/messagePopupConfig.coffee | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/client/views/app/messagePopupConfig.coffee b/client/views/app/messagePopupConfig.coffee index 6d72aad25af..1fc657a759a 100644 --- a/client/views/app/messagePopupConfig.coffee +++ b/client/views/app/messagePopupConfig.coffee @@ -116,12 +116,14 @@ Template.messagePopupConfig.helpers getInput: self.getInput getFilter: (collection, filter) -> results = [] + key = ':' + filter # show common used emojis, when use input a single ':' if filter == '' commonEmojis = [ ':laughing:', ':smiley:', + ':stuck_out_tongue:', ':sunglasses:', ':wink:', ':innocent:', @@ -137,18 +139,29 @@ Template.messagePopupConfig.helpers data: collection[shortname] return results; - for shortname, data of collection - if shortname.indexOf(filter) > -1 + # use ascii + for shortname, value of RocketChat.emoji.asciiList + if results.length > 10 + break + + if shortname.startsWith(key) results.push _id: shortname - data: data + data: [value] + # use shortnames + for shortname, data of collection if results.length > 10 break - if filter.length >= 3 - results.sort (a, b) -> - a.length > b.length + if shortname.startsWith(key) + results.push + _id: shortname + data: data + + #if filter.length >= 3 + results.sort (a, b) -> + a._id.length - b._id.length return results @@ -167,4 +180,3 @@ Template.messagePopupConfig.onCreated -> @autorun -> template.channelSubscription = template.subscribe 'channelAutocomplete', template.channelFilter.get() -