Always load full threads

This is the first step in the real-threading mod that I'm
working on.
This commit is contained in:
Jason McBrayer 2019-07-19 09:56:52 -04:00
parent 5b7d4e0b68
commit ef94e057f7
2 changed files with 20 additions and 18 deletions

View File

@ -18,14 +18,13 @@ mastodon.status_context(<numerical id>)
<h1 id="title" class="title">
Thread
</h1>
{% for ancestor in ancestors %}
{% include "main/toot_partial.html" with toot=ancestor %}
<hr class="is-hidden">
{% endfor %}
{% include "main/toot_partial.html" with toot=toot active=True %}
<hr class="is-hidden">
{% include "main/toot_partial.html" with toot=root %}
{% for descendant in descendants %}
{% if descendant == toot %}
{% include "main/toot_partial.html" with toot=toot active=True %}
{% else %}
{% include "main/toot_partial.html" with toot=descendant %}
{% endif %}
<hr class="is-hidden">
{% endfor %}
@ -35,4 +34,3 @@ mastodon.status_context(<numerical id>)
</script>
{% endif %}
{% endblock %}

View File

@ -608,16 +608,19 @@ def note(request, next=None, prev=None):
@br_login_required
def thread(request, id):
account, mastodon = get_usercontext(request)
toot = mastodon.status(id)
root = toot
try:
context = mastodon.status_context(id)
if context.ancestors and len(context.ancestors) > 0:
root = context.ancestors[0]
context = mastodon.status_context(context.ancestors[0])
except MastodonNotFoundError:
raise Http404(_("Thread not found; the message may have been deleted."))
toot = mastodon.status(id)
notifications = _notes_count(account, mastodon)
filters = get_filters(mastodon, context="thread")
# Apply filters
ancestors = [x for x in context.ancestors if not toot_matches_filters(x, filters)]
descendants = [
x for x in context.descendants if not toot_matches_filters(x, filters)
]
@ -628,7 +631,7 @@ def thread(request, id):
{
"context": context,
"toot": toot,
"ancestors": ancestors,
"root": root,
"descendants": descendants,
"own_acct": request.session["active_user"],
"notifications": notifications,
@ -1617,6 +1620,7 @@ def accounts(request, id=None):
},
)
@br_login_required
def vote(request, id):
if request.method == "GET":
@ -1629,16 +1633,16 @@ def vote(request, id):
return redirect("thread", id)
# radio buttons
if "poll-single" in request.POST.keys():
mastodon.poll_vote(poll.id, request.POST['poll-single'])
mastodon.poll_vote(poll.id, request.POST["poll-single"])
# checkboxes
else:
values = [x for x in request.POST.getlist('poll-multiple')]
values = [x for x in request.POST.getlist("poll-multiple")]
if values:
mastodon.poll_vote(poll.id, values)
if request.POST.get("ic-request"):
return render(request,
"main/toot_partial.html",
{"toot": mastodon.status(id) })
return render(
request, "main/toot_partial.html", {"toot": mastodon.status(id)}
)
else:
return redirect("thread", id)