about summary refs log tree commit diff
path: root/app/assets/javascripts/components
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-18 12:51:09 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-18 12:51:09 +0200
commitab7291b8fe78bc03375bb64e3b458488fa8ce96a (patch)
tree29ebb5b2a3bfbe5efd8ddad5205ef044bb1e0f51 /app/assets/javascripts/components
parentdfd5deacf4211b4736e0981ea2d5d9dfca6abc62 (diff)
Add ancestors/descendants during normalization in timeline reducer
This way replies will appear in the detailed view live if they are from
statuses that would be delivered to the user normally
Diffstat (limited to 'app/assets/javascripts/components')
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 462c10733..522d6be39 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -28,7 +28,23 @@ function statusToMaps(state, status) {
     state  = statusToMaps(state, reblog);
   }
 
+  // Replies
+  if (status.get('in_reply_to_id')) {
+    state = state.updateIn(['descendants', status.get('in_reply_to_id')], set => {
+      if (!Immutable.OrderedSet.isOrderedSet(set)) {
+        return Immutable.OrderedSet([status.get('id')]);
+      } else {
+        return set.add(status.get('id'));
+      }
+    });
+  }
+
   return state.withMutations(map => {
+    if (status.get('in_reply_to_id')) {
+      map.updateIn(['descendants', status.get('in_reply_to_id')], Immutable.OrderedSet(), set => set.add(status.get('id')));
+      map.updateIn(['ancestors', status.get('id')], Immutable.OrderedSet(), set => set.add(status.get('in_reply_to_id')));
+    }
+
     map.setIn(['accounts', account.get('id')], account);
     map.setIn(['statuses', status.get('id')], status);
   });
@@ -68,12 +84,12 @@ function contextToMaps(state, status, ancestors, descendants) {
   let ancestorsIds = ancestors.map(ancestor => {
     state = statusToMaps(state, ancestor);
     return ancestor.get('id');
-  });
+  }).toOrderedSet();
 
   let descendantsIds = descendants.map(descendant => {
     state = statusToMaps(state, descendant);
     return descendant.get('id');
-  });
+  }).toOrderedSet();
 
   return state.withMutations(map => {
     map.setIn(['ancestors', status.get('id')], ancestorsIds);