about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-10-10 15:18:12 +0200
committerGitHub <noreply@github.com>2017-10-10 15:18:12 +0200
commit4bb3e4eeba3002ecae98efe6e1a0c05776fb2308 (patch)
treed139b99c108d7cb1bc5b3f261d2ca5ec647d8c74
parent784c7510d762f9c7206812abeade03d8f4afa611 (diff)
Fix #5295 - Order custom emoji lexicographically (#5297)
-rw-r--r--app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js17
1 files changed, 16 insertions, 1 deletions
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 4fa93f6b0..8708f8cba 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),