From: Dessalines Date: Tue, 16 Jul 2019 05:56:46 +0000 (-0700) Subject: Adding collapse comments X-Git-Url: http://these/git/%7B%60https:/readmes/README.ja.md?a=commitdiff_plain;h=7ee486081e0ef099ba8e0b26b6001278b89a6482;p=lemmy.git Adding collapse comments - Fixes #179 --- diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index a69ae06f..5181e45e 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -84,6 +84,8 @@ export class CommentForm extends Component { if (i.props.node) { i.props.onReplyCancel(); } + + autosize.update(document.querySelector('textarea')); } handleCommentContentChange(i: CommentForm, event: any) { diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 126966a7..aa7dfbe3 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -19,6 +19,7 @@ interface CommentNodeState { banReason: string; banExpires: string; banType: BanType; + collapsed: boolean; } interface CommentNodeProps { @@ -41,7 +42,8 @@ export class CommentNode extends Component { showBanDialog: false, banReason: null, banExpires: null, - banType: BanType.Community + banType: BanType.Community, + collapsed: false, } constructor(props: any, context: any) { @@ -88,9 +90,12 @@ export class CommentNode extends Component {
  • +
  • +
    {this.state.collapsed ? '[+]' : '[-]'}
    +
  • {this.state.showEdit && } - {!this.state.showEdit && + {!this.state.showEdit && !this.state.collapsed &&
      @@ -202,7 +207,7 @@ export class CommentNode extends Component { disabled={this.props.locked} /> } - {this.props.node.children && + {this.props.node.children && !this.state.collapsed && { admins={this.props.admins} /> } + {/* A collapsed clearfix */} + {this.state.collapsed &&
      }
    ) } @@ -430,4 +437,9 @@ export class CommentNode extends Component { let then = moment.utc(this.props.node.comment.published); return now.isBefore(then); } + + handleCommentCollapse(i: CommentNode) { + i.state.collapsed = !i.state.collapsed; + i.setState(i.state); + } }