maksverver / astral-codex-eleven

A Chrome browser extension to speed up loading of posts on https://www.astralcodexten.com/ by replacing the comments widget.
MIT License
4 stars 2 forks source link

Refactor comment api #15

Closed Pycea closed 4 months ago

Pycea commented 4 months ago

Improves separation of options and comments.

  1. Removes dependency of ExtComment(List)Component on option api. Comments are now completely separate from options, and option functions are called on comments externally. Also removes the requirement of the option value to be truthy in order for processComment to run, instead passing the current value to the function.

  2. Separates out functions to create the reply/edit/delete buttons. Perhaps more controversially, removes the connectCommentEditor and enableCommentReply functions. While this does lead to a bit more redundancy, the nested callback structure and numerous params seem to cost more clarity than they're worth. I'd also argue that while replying to a comment and creating a top level comment happen to do similar things, they're not an inherent logical grouping.

    Instead, some of the redundant functionality, like hiding and showing elements and removing the edit box, has been moved to the CommentEditorComponent class.