about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOndřej Hruška <ondra@ondrovo.com>2017-09-20 21:39:22 +0200
committerOndřej Hruška <ondra@ondrovo.com>2017-09-20 21:39:22 +0200
commit4f9a493d9d0bb6d502dded619f7ac9d4064452ca (patch)
tree49913219a53b43db330e2f636cda18ece71d516e
parent8c0733a14e0480f40b8f39933bccf4de94b11aa0 (diff)
cache allShortcodes
-rw-r--r--app/javascript/mastodon/actions/compose.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js
index b47fbc8ba..fc154f90a 100644
--- a/app/javascript/mastodon/actions/compose.js
+++ b/app/javascript/mastodon/actions/compose.js
@@ -213,6 +213,8 @@ export function clearComposeSuggestions() {
   };
 };
 
+let allShortcodes = null; // cached list of all shortcodes for suggestions
+
 export function fetchComposeSuggestions(token) {
   let leading = token[0];
 
@@ -231,8 +233,10 @@ export function fetchComposeSuggestions(token) {
     };
   } else if (leading === ':') {
     // shortcode
-    let allShortcodes = Object.keys(emojione.emojioneList);
-    // TODO when we have custom emojons merged, add them to this shortcode list
+    if (!allShortcodes) {
+      allShortcodes = Object.keys(emojione.emojioneList);
+      // TODO when we have custom emojons merged, add them to this shortcode list
+    }
     return (dispatch) => {
       dispatch(readyComposeSuggestionsTxt(token, allShortcodes.filter((sc) => {
         return sc.indexOf(token) === 0;