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-19 18:20:19 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-19 18:20:19 +0200
commit04bbc576906ff70feed7d42fef0e6db17fdd9ed3 (patch)
tree789e41ff1abc26044dd230ca05b0aa517e98c453 /app/assets/javascripts/components/reducers
parent8698cd3281ac1d699c723a151b14f1e2f2e8b07e (diff)
Fix #100 - Add "back" button to certain views
Also fix reloading of timelines after merge-type events
Diffstat (limited to 'app/assets/javascripts/components/reducers')
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 06534971d..331cbf59c 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -77,7 +77,7 @@ function normalizeStatus(state, status) {
   });
 };
 
-function normalizeTimeline(state, timeline, statuses) {
+function normalizeTimeline(state, timeline, statuses, replace = false) {
   let ids = Immutable.List([]);
 
   statuses.forEach((status, i) => {
@@ -85,7 +85,7 @@ function normalizeTimeline(state, timeline, statuses) {
     ids   = ids.set(i, status.get('id'));
   });
 
-  return state.update(timeline, list => list.unshift(...ids));
+  return state.update(timeline, list => (replace ? ids : list.unshift(...ids)));
 };
 
 function appendNormalizedTimeline(state, timeline, statuses) {
@@ -99,7 +99,7 @@ function appendNormalizedTimeline(state, timeline, statuses) {
   return state.update(timeline, list => list.push(...moreIds));
 };
 
-function normalizeAccountTimeline(state, accountId, statuses) {
+function normalizeAccountTimeline(state, accountId, statuses, replace = false) {
   let ids = Immutable.List([]);
 
   statuses.forEach((status, i) => {
@@ -107,7 +107,7 @@ function normalizeAccountTimeline(state, accountId, statuses) {
     ids   = ids.set(i, status.get('id'));
   });
 
-  return state.updateIn(['accounts_timelines', accountId], Immutable.List([]), list => list.unshift(...ids));
+  return state.updateIn(['accounts_timelines', accountId], Immutable.List([]), list => (replace ? ids : list.unshift(...ids)));
 };
 
 function appendNormalizedAccountTimeline(state, accountId, statuses) {
@@ -217,7 +217,7 @@ function normalizeSuggestions(state, accounts) {
 export default function timelines(state = initialState, action) {
   switch(action.type) {
     case TIMELINE_REFRESH_SUCCESS:
-      return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
+      return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses), action.replace);
     case TIMELINE_EXPAND_SUCCESS:
       return appendNormalizedTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
     case TIMELINE_UPDATE:
@@ -243,7 +243,7 @@ export default function timelines(state = initialState, action) {
     case STATUS_FETCH_SUCCESS:
       return normalizeContext(state, Immutable.fromJS(action.status), Immutable.fromJS(action.context.ancestors), Immutable.fromJS(action.context.descendants));
     case ACCOUNT_TIMELINE_FETCH_SUCCESS:
-      return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
+      return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
     case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
       return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
     case SUGGESTIONS_FETCH_SUCCESS: