about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/custom_emojis.js
diff options
context:
space:
mode:
authorIsatis <515462+Reverite@users.noreply.github.com>2018-04-04 13:25:34 -0700
committerEugen Rochko <eugen@zeonfederated.com>2018-04-04 22:25:34 +0200
commitb08ab329f4d149fd414e0539574f49062c571a8a (patch)
tree0e99cecdab27a0bbe4e745284726dcd1905f6fac /app/javascript/mastodon/reducers/custom_emojis.js
parentf1867a73881444dfed9e093425435681ee764922 (diff)
retrieve custom emoji list via API instead of before page load (#7047)
Diffstat (limited to 'app/javascript/mastodon/reducers/custom_emojis.js')
-rw-r--r--app/javascript/mastodon/reducers/custom_emojis.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/app/javascript/mastodon/reducers/custom_emojis.js b/app/javascript/mastodon/reducers/custom_emojis.js
index 307bcc7dc..d2c801ade 100644
--- a/app/javascript/mastodon/reducers/custom_emojis.js
+++ b/app/javascript/mastodon/reducers/custom_emojis.js
@@ -1,16 +1,15 @@
-import { List as ImmutableList } from 'immutable';
-import { STORE_HYDRATE } from '../actions/store';
+import { List as ImmutableList, fromJS as ConvertToImmutable } from 'immutable';
+import { CUSTOM_EMOJIS_FETCH_SUCCESS } from '../actions/custom_emojis';
 import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
 import { buildCustomEmojis } from '../features/emoji/emoji';
 
-const initialState = ImmutableList();
+const initialState = ImmutableList([]);
 
 export default function custom_emojis(state = initialState, action) {
-  switch(action.type) {
-  case STORE_HYDRATE:
-    emojiSearch('', { custom: buildCustomEmojis(action.state.get('custom_emojis', [])) });
-    return action.state.get('custom_emojis');
-  default:
-    return state;
+  if(action.type === CUSTOM_EMOJIS_FETCH_SUCCESS) {
+    state = ConvertToImmutable(action.custom_emojis);
+    emojiSearch('', { custom: buildCustomEmojis(state) });
   }
+
+  return state;
 };