Optionally get post context when loading timelines
Down the line I'd like to implement something on my frontend similar to what Gab is doing. Timelines show comment replies for each post, directly in the timeline.
However, the way Gab is doing it looks like this...
I think it would be better if instead we could get status list endpoints with ?with_context=true
, eg:
/api/v1/timelines/home?with_context=true
/api/v1/accounts/:id/statuses?with_context=true
This returned data would add a context
field to each status, containing the data needed to render the posts.
Normally context responses (/api/v1/statuses/:id/context
) look like this:
{
"ancestors": ['...'],
"descendants": ['...']
}
I think a ?with_context=true
response could look like this:
[{
"id": "1",
"content": "Hello world!",
// ...
"context": {
"ancestors": [],
"descendants": ['...'],
"stats": {
"total_ancestors": 0,
"total_descendants": 100
},
}
}, {
"id": "2",
"content": "What's up?",
// ...
"context": {
"ancestors": ['...'],
"descendants": ['...'],
"stats": {
"total_ancestors": 25,
"total_descendants": 3
},
}
}]
It would return 2 descendants, and 1 ancestor (Pleroma-configurable). The stats
are there so the frontend can say things like "Click to view ${X} total replies".
Since timelines are chronological, getting the ancestors
will be most useful for new posts (no mockup yet, but it could show the post being replied to), while descendants
would be most useful for user pages and when scrolling through timelines.