about summary refs log tree commit diff
path: root/app/assets/javascripts/components
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-17 01:34:16 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-17 01:34:16 +0200
commite865673175388d4af306a060567567569ba646dc (patch)
treeb80cf5db2e89475c4a6e80ff86b3a4af84b0f8e3 /app/assets/javascripts/components
parentb5c6d00afae53dca1b6abd405556d58557ea7e1a (diff)
Fix #82 - only show latest reblog of status in UI
Diffstat (limited to 'app/assets/javascripts/components')
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index d4c6d43b4..2059079eb 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -123,7 +123,18 @@ function appendNormalizedAccountTimeline(state, accountId, statuses) {
 
 function updateTimeline(state, timeline, status) {
   state = normalizeStatus(state, status);
-  state = state.update(timeline, list => list.unshift(status.get('id')));
+
+  state = state.update(timeline, list => {
+    const reblogOfId = status.getIn(['reblog', 'id'], null);
+
+    if (reblogOfId !== null) {
+      const otherReblogs = state.get('statuses').filter(item => item.get('reblog') === reblogOfId).map((_, itemId) => itemId);
+      list = list.filterNot(itemId => itemId === reblogOfId || otherReblogs.includes(itemId));
+    }
+
+    return list.unshift(status.get('id'));
+  });
+
   state = state.updateIn(['accounts_timelines', status.getIn(['account', 'id'])], Immutable.List([]), list => (list.includes(status.get('id')) ? list : list.unshift(status.get('id'))));
 
   return state;