comments.html: refactor so that something can be sanely
changed in it
the comments.html template (along with submission.html) has numerous
undesirable properties which i will describe now. unless you are very
familiar with the codebase, it can be extremely difficult to grok.
this is pretty insane as there is nothing fundamentally complex about
the goal of comments.html: return a component that shows a username
and info, reports if any, comment content, and actions a user can
take.
this behemeoth was initially 886 lines in the old version of this
codebase, and this is with awards and a lot of other cruft removed.
anyway, the maintainability of this file is about on par with some
legacy application that keels over and dies if you sneeze vaguely
in its direction.
the nicest thing i can say about it is that it isn't currently
crashing.
anyway some of the problems include:
large, splittable components, are not split into separate files.
this makes it incredibly difficult to find or make changes across
the template and makes it nearly impossible to find or change a
specific thing.
this is most easily exemplified in the modals, which should by all
accounts be separate templates, just inlined into comments.html.
this is what this pull request does most. while it doesn't change
too much of the core logic (a lot of it is duplicated for example
in submission.html and this PR doesn't touch this, this does at
least make it so that changes to the broader template or pieces
of the template can be changed without staring at it for hours.
the nesting is oftentimes incorrect.
inexplicably, probably out of laziness from when the code was first
written, things will end up fully left aligned, while multiple layers
deep into a nesting context.
if an if statement or an endif is changed, it is incredibly
difficult to figure out where the error was. you can't trust the
nesting.
multiple repeated checks for things that are always true.
this is probably a symptom of the above two problems but it's very
noticeable once you fix the nesting. for example there is a block
near the very top of the actions bar which checks for
parent_submission which effectively checks "is this in a post" (this
commit won't complain about parent_submission checks but i do have
opinions on those).
all of the action buttons further down the chain also check for
parent_submission, or even check inconsistently (by using if c.post)
within this context this is a completely unnecessary check in this
context.
while it is potentially useful (and in fact because #251 requires we
dismantle the assumption a little bit) to have these checks now, the
fact that they were initially added shows that when the code was all
initial written, there was little care into thinking about comment
state.
mobile actions are duplicated and duplicated inline.
i actually do find it probably pretty hard to support this normally
given the codebase's DOM so whatever, duplicate the things, but if
we're going to do that, inlining it into the middle of an incredibly
long template is really difficult to comprehend as a design decision.
...anyway yeah this PR intends to fix these problems and enable work
to be done on #251. this is a "perfect is the enemy of good" commit.
it doesn't change much fundamental and is not intended to erase the
sins of the original file, but at least make it maintainable.
this also fixes a minor bug with #473 where the GIF modal was left
in by accident.
comments.html: refactor so that something can be sanely changed in it
the comments.html template (along with submission.html) has numerous undesirable properties which i will describe now. unless you are very familiar with the codebase, it can be extremely difficult to grok.
this is pretty insane as there is nothing fundamentally complex about the goal of comments.html: return a component that shows a username and info, reports if any, comment content, and actions a user can take.
this behemeoth was initially 886 lines in the old version of this codebase, and this is with awards and a lot of other cruft removed. anyway, the maintainability of this file is about on par with some legacy application that keels over and dies if you sneeze vaguely in its direction.
the nicest thing i can say about it is that it isn't currently crashing.
anyway some of the problems include:
this makes it incredibly difficult to find or make changes across the template and makes it nearly impossible to find or change a specific thing.
this is most easily exemplified in the modals, which should by all accounts be separate templates, just inlined into comments.html.
this is what this pull request does most. while it doesn't change too much of the core logic (a lot of it is duplicated for example in submission.html and this PR doesn't touch this, this does at least make it so that changes to the broader template or pieces of the template can be changed without staring at it for hours.
inexplicably, probably out of laziness from when the code was first written, things will end up fully left aligned, while multiple layers deep into a nesting context.
if an if statement or an endif is changed, it is incredibly difficult to figure out where the error was. you can't trust the nesting.
this is probably a symptom of the above two problems but it's very noticeable once you fix the nesting. for example there is a block near the very top of the actions bar which checks for parent_submission which effectively checks "is this in a post" (this commit won't complain about parent_submission checks but i do have opinions on those).
all of the action buttons further down the chain also check for parent_submission, or even check inconsistently (by using if c.post) within this context this is a completely unnecessary check in this context.
while it is potentially useful (and in fact because #251 requires we dismantle the assumption a little bit) to have these checks now, the fact that they were initially added shows that when the code was all initial written, there was little care into thinking about comment state.
i actually do find it probably pretty hard to support this normally given the codebase's DOM so whatever, duplicate the things, but if we're going to do that, inlining it into the middle of an incredibly long template is really difficult to comprehend as a design decision.
...anyway yeah this PR intends to fix these problems and enable work to be done on #251. this is a "perfect is the enemy of good" commit. it doesn't change much fundamental and is not intended to erase the sins of the original file, but at least make it maintainable.
this also fixes a minor bug with #473 where the GIF modal was left in by accident.