about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-15 12:06:30 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-15 12:06:30 +0200
commit20f581f79669118a1a4052408078d53c7bbe83f2 (patch)
tree4fa86d90bdb0b92ce300b95fa9f3661d16b154b7 /app/assets/javascripts/components/reducers
parente21a3fe0cd91dfeae76bce4d58c7611e78b60fbf (diff)
Display follow suggestions
Diffstat (limited to 'app/assets/javascripts/components/reducers')
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 927ac28fd..9fb84b585 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -25,6 +25,7 @@ import {
   STATUS_DELETE_SUCCESS
 }                                from '../actions/statuses';
 import { FOLLOW_SUBMIT_SUCCESS } from '../actions/follow';
+import { SUGGESTIONS_FETCH_SUCCESS } from '../actions/suggestions';
 import Immutable                 from 'immutable';
 
 const initialState = Immutable.Map({
@@ -37,7 +38,8 @@ const initialState = Immutable.Map({
   me: null,
   ancestors: Immutable.Map(),
   descendants: Immutable.Map(),
-  relationships: Immutable.Map()
+  relationships: Immutable.Map(),
+  suggestions: Immutable.List([])
 });
 
 function normalizeStatus(state, status) {
@@ -189,6 +191,14 @@ function normalizeContext(state, status, ancestors, descendants) {
   });
 };
 
+function normalizeSuggestions(state, accounts) {
+  accounts.forEach(account => {
+    state = state.setIn(['accounts', account.get('id')], account);
+  });
+
+  return state.set('suggestions', accounts.map(account => account.get('id')));
+};
+
 export default function timelines(state = initialState, action) {
   switch(action.type) {
     case TIMELINE_REFRESH_SUCCESS:
@@ -221,6 +231,8 @@ export default function timelines(state = initialState, action) {
       return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
     case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
       return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
+    case SUGGESTIONS_FETCH_SUCCESS:
+      return normalizeSuggestions(state, Immutable.fromJS(action.suggestions));
     default:
       return state;
   }