diff --git a/files/classes/submission.py b/files/classes/submission.py index ffb4513bf..d081b700e 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -345,8 +345,8 @@ class Submission(Base): url = self.url.replace("old.reddit.com", v.reddit) if '/comments/' in url and "sort=" not in url: - if "?" in url: url += "&context=9" - else: url += "?context=8" + if "?" in url: url += f"&context={RENDER_DEPTH_LIMIT}" + else: url += f"?context={RENDER_DEPTH_LIMIT - 1}" if v.controversial: url += "&sort=controversial" return url elif self.url: diff --git a/files/helpers/const.py b/files/helpers/const.py index 687870682..c6d3d583d 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -55,6 +55,10 @@ ERROR_MESSAGES = { } LOGGEDIN_ACTIVE_TIME = 15 * 60 +RENDER_DEPTH_LIMIT = 9 +''' +The maximum depth at which a comment tree is rendered +''' WERKZEUG_ERROR_DESCRIPTIONS = { 400: "The browser (or proxy) sent a request that this server could not understand.", diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 20174e2c6..8401749b6 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -84,6 +84,7 @@ def inject_constants(): "COLORS":COLORS, "THEMES":THEMES, "PERMS":PERMS, + "RENDER_DEPTH_LIMIT":RENDER_DEPTH_LIMIT, } diff --git a/files/routes/posts.py b/files/routes/posts.py index 08f778214..cf01ee780 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -259,7 +259,7 @@ def morecomments(v, cid): votes.c.vote_type, blocking.c.target_id, blocked.c.target_id, - ).filter(Comment.top_comment_id == tcid, Comment.level > 9).join( + ).filter(Comment.top_comment_id == tcid, Comment.level > RENDER_DEPTH_LIMIT).join( votes, votes.c.comment_id == Comment.id, isouter=True diff --git a/files/templates/comments.html b/files/templates/comments.html index 6ea8d1e93..32cc69fb5 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -72,20 +72,15 @@