From 4c6adaf4f4568a577e32ec52e84d4f95eacf8a94 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 10 Oct 2017 15:18:12 +0200 Subject: [PATCH] Fix #5295 - Order custom emoji lexicographically (#5297) --- .../emoji_picker_dropdown_container.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js b/app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js index 4fa93f6b03..8708f8cba1 100644 --- a/app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js +++ b/app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js @@ -18,8 +18,23 @@ const getFrequentlyUsedEmojis = createSelector([ .toArray() ); +const getCustomEmojis = createSelector([ + state => state.get('custom_emojis'), +], emojis => emojis.sort((a, b) => { + const aShort = a.get('shortcode').toLowerCase(); + const bShort = b.get('shortcode').toLowerCase(); + + if (aShort < bShort) { + return -1; + } else if (aShort > bShort ) { + return 1; + } else { + return 0; + } +})); + const mapStateToProps = state => ({ - custom_emojis: state.get('custom_emojis'), + custom_emojis: getCustomEmojis(state), autoPlay: state.getIn(['meta', 'auto_play_gif']), skinTone: state.getIn(['settings', 'skinTone']), frequentlyUsedEmojis: getFrequentlyUsedEmojis(state),