commit: 7a9212dfebcca48721433955c4b150e0c67f7803
parent: 00bd10fabf620791985e9b5e2e504f0d09a0c86f
Author: Morgan Bazalgette <the@howl.moe>
Date: Sun, 1 Apr 2018 21:57:55 +0200
Temporary workaround to only show related statuses
Fixes #3. Proper fix will come when pleroma/pleroma#111 is closed.
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/app/javascript/mastodon/actions/statuses.js b/app/javascript/mastodon/actions/statuses.js
@@ -167,6 +167,33 @@ export function fetchContext(id) {
dispatch(fetchContextRequest(id));
api(getState).get(`/api/v1/statuses/${id}/context`).then(response => {
+ // PLEROMA TEMP FIX
+ // If we already have the status, we can do some preprocessing on descendants & ancestors.
+ const status = getState().getIn(['statuses', id], null);
+ if (status) {
+ console.log("we have the status already - we can do preproc on ancestors");
+ // Filter posts so that they're in our same branch
+ let nextID = status.get("in_reply_to_id");
+ console.log(status, response.data.ancestors);
+ response.data.ancestors = response.data.ancestors.reverse().filter(s => {
+ if (s.in_reply_to_id == null || s.id == nextID) {
+ nextID = s.in_reply_to_id;
+ return true;
+ }
+ return false;
+ }).reverse();
+ }
+
+ const allowedIDs = {};
+ allowedIDs[id] = true;
+ response.data.descendants = response.data.descendants.filter(s => {
+ if (s.in_reply_to_id in allowedIDs) {
+ allowedIDs[s.id] = true;
+ return true;
+ }
+ return false;
+ });
+
dispatch(importFetchedStatuses(response.data.ancestors.concat(response.data.descendants)));
dispatch(fetchContextSuccess(id, response.data.ancestors, response.data.descendants));