about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-10-10 20:47:14 +0200
committerGitHub <noreply@github.com>2017-10-10 20:47:14 +0200
commit9815be2a441f8c8c4fb4adbc9cc1713a1cc4b898 (patch)
tree4159136ff987c3d3a60031897287ab504cbcedd5 /app/javascript
parentbebaa6eced0af2665d105beb59bd21030425245a (diff)
Fix #5293 - Pre-fill frequently used emojis to avoid bugs (#5305)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/features/compose/containers/emoji_picker_dropdown_container.js32
1 files changed, 29 insertions, 3 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 8708f8cba..71944128c 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
@@ -8,15 +8,41 @@ import { useEmoji } from '../../../actions/emojis';
 const perLine = 8;
 const lines   = 2;
 
+const DEFAULTS = [
+  '+1',
+  'grinning',
+  'kissing_heart',
+  'heart_eyes',
+  'laughing',
+  'stuck_out_tongue_winking_eye',
+  'sweat_smile',
+  'joy',
+  'yum',
+  'disappointed',
+  'thinking_face',
+  'weary',
+  'sob',
+  'sunglasses',
+  'heart',
+  'ok_hand',
+];
+
 const getFrequentlyUsedEmojis = createSelector([
   state => state.getIn(['settings', 'frequentlyUsedEmojis'], ImmutableMap()),
-], emojiCounters => emojiCounters
+], emojiCounters => {
+  let emojis = emojiCounters
     .keySeq()
     .sort((a, b) => emojiCounters.get(a) - emojiCounters.get(b))
     .reverse()
     .slice(0, perLine * lines)
-    .toArray()
-);
+    .toArray();
+
+  if (emojis.length < DEFAULTS.length) {
+    emojis = emojis.concat(DEFAULTS.slice(0, DEFAULTS.length - emojis.length));
+  }
+
+  return emojis;
+});
 
 const getCustomEmojis = createSelector([
   state => state.get('custom_emojis'),