diff --git a/brutaldon/threadtree.py b/brutaldon/threadtree.py index fe49144..a9cc416 100644 --- a/brutaldon/threadtree.py +++ b/brutaldon/threadtree.py @@ -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 diff --git a/brutaldon/views.py b/brutaldon/views.py index c25b7e2..765f29e 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -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",