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:38:28 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-15 12:38:28 +0200
commit70ab6624f5f397ddd05136db2fa37c902f0867eb (patch)
tree72407fd4b5368d3e8cdfd4c85ae928a654d8d261 /app/assets/javascripts/components/reducers
parent91144d46ecc1a6e2d39abe8bea2d62c5cb57aca3 (diff)
parent4d336ceface783c255e62220cfa76812630ff1a1 (diff)
Merge branch 'feature-suggestions' into development
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;
   }