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:
parent
e424765fc4
commit
5095718192
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue