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,21 +18,19 @@ mastodon.status_context(<numerical id>)
<h1 id="title" class="title"> <h1 id="title" class="title">
Thread Thread
</h1> </h1>
{% for ancestor in ancestors %} {% include "main/toot_partial.html" with toot=root %}
{% 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">
{% for descendant in descendants %} {% for descendant in descendants %}
{% include "main/toot_partial.html" with toot=descendant %} {% if descendant == toot %}
<hr class="is-hidden"> {% 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 %} {% endfor %}
{% if not preferences.no_javascript %} {% if not preferences.no_javascript %}
<script type="application/javascript"> <script type="application/javascript">
Intercooler.ready(expandCWButtonPrepare); Intercooler.ready(expandCWButtonPrepare);
</script> </script>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

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