Skip to content
Snippets Groups Projects
Verified Commit 7a9212df authored by Morgan Bazalgette's avatar Morgan Bazalgette
Browse files

Temporary workaround to only show related statuses

Fixes #3. Proper fix will come when pleroma#111 is closed.
parent 00bd10fa
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment