The root post is not included in its descendants

Oh for Pete's sake I'm an idiot. The descendants array isn't going to contain the root post at all, because it's totally separate. That's the missing post everything was trying to reply to!
This commit is contained in:
Cy 2020-06-01 02:38:17 +00:00 committed by Cy
parent 5187715244
commit 2cf2e777d4
2 changed files with 6 additions and 5 deletions

View File

@ -1,9 +1,10 @@
from pprint import pprint
def maketree(mastodon, descendants):
def maketree(mastodon, root, descendants):
lookup = dict((descendant.id, descendant) for descendant in descendants)
lookup[root.id] = root
replies = {}
roots = set()
roots = set([root.id])
def lookup_or_fetch(id):
if not id in lookup:
lookup[id] = mastodon.status(id)
@ -64,8 +65,8 @@ def unmaketree(tree):
yield from unmaketree(children)
yield OUT
def build(mastodon, descendants):
tree, leftover = maketree(mastodon, descendants)
def build(mastodon, root, descendants):
tree, leftover = maketree(mastodon, root, descendants)
yield IN
yield from unmaketree(tree)
yield OUT

View File

@ -692,7 +692,7 @@ def thread(request, id):
# descendants = [
# x for x in context.descendants if not toot_matches_filters(x, filters)
# ]
toots = tuple(threadtree.build(mastodon, context.descendants))
toots = tuple(threadtree.build(mastodon, root, context.descendants))
return render(
request,
"main/thread.html",